Created
October 7, 2012 13:03
-
-
Save iso100/3848332 to your computer and use it in GitHub Desktop.
jQuery for Tracking Outbound Links in GA
This file contains hidden or 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
$('#content a:not(.popupwindow)').filter(function() { | |
var theHref = this; | |
if (theHref.hostname && theHref.hostname !== location.hostname) { | |
$(theHref).not(".noAutoIcon").addClass("offSite"); | |
$(theHref).not(".noAutoLink").attr('target','_blank').bind('click keypress', function(event) { | |
var code=event.charCode || event.keyCode; | |
if (!code || (code && code == 13)) { | |
if(pageTracker){ | |
var fixedLink = this.href; | |
fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1"); | |
fixedLink = '/outgoing/' + fixedLink; | |
pageTracker._trackPageview(fixedLink); | |
}; | |
}; | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment