Created
August 30, 2013 23:03
-
-
Save ethanhinson/6395125 to your computer and use it in GitHub Desktop.
Easy cross domain tracking with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Drupal.behaviors.crossDomainTracking = { | |
attach: function(context, settings) { | |
//Catch all outgoing links for a specific domain | |
$('a[href*="mydomain.com"]').click(function() { | |
_gaq.push(['_link', this.href]); | |
return false; | |
}); | |
// Add onSubmit _linkByPost to all <form> elements for a specific domain | |
$('form[action*="mydomain.com"]').attr('onSubmit','_gaq.push(["_linkByPost", this])'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment