Skip to content

Instantly share code, notes, and snippets.

@ctbarna
Created April 27, 2011 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctbarna/944808 to your computer and use it in GitHub Desktop.
Save ctbarna/944808 to your computer and use it in GitHub Desktop.
Track External Links with Google Analytics
var gaParentDiv = ""; // Only change links in this selector including trailing space.
var trackingBase = "/ext/";
$(parentDiv+"a[href^=http\\:\\/\\/]:not(a[href*=\\/"+document.domain+"])").click(function () {
pageTracker._trackPageview(trackingBase+$(this).attr("href"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment