Skip to content

Instantly share code, notes, and snippets.

@timsnadden
Created February 27, 2012 21:21
Show Gist options
  • Save timsnadden/1927187 to your computer and use it in GitHub Desktop.
Save timsnadden/1927187 to your computer and use it in GitHub Desktop.
jQuery Google Analytics outbound link tracking
// Need to delay external links to allow analytics to fire
$('a[href^="http"]').on('click', function(e){
e.preventDefault();
_gaq.push(['_trackEvent', 'Outbound', 'click', this.href]);
window.setTimeout(function() {
window.location = arguments[0];
}, 200, this.href);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment