Skip to content

Instantly share code, notes, and snippets.

@gmurphey
Created June 7, 2012 16:27
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 gmurphey/2889880 to your computer and use it in GitHub Desktop.
Save gmurphey/2889880 to your computer and use it in GitHub Desktop.
Outbound link tracking with GA and jQuery
(function ($) {
$(function () {
$('a[href^="https?:"]:not(a[href^="https?://' + document.location.hostname + '"])').click(function () {
try { _gat._getTrackerByName()._trackEvent('Outbound Links', $(this).attr('href')); } catch (e) {}
});
});
}) (jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment