Created
February 27, 2012 21:21
-
-
Save timsnadden/1927187 to your computer and use it in GitHub Desktop.
jQuery Google Analytics outbound link tracking
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
// 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