Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save felipelavinz/3912625 to your computer and use it in GitHub Desktop.
Save felipelavinz/3912625 to your computer and use it in GitHub Desktop.
Event tracking when using multiple Google Analytics accounts
(function($){
$(document).ready(function(){
$('a[href$=".pdf"]').click(function(){
var trackers = _gat._getTrackers(),
specific_tracker = trackers[ trackers.length - 1 ], // assuming that the last tracker it's the one where you want to track the events
dl_url = $(this).attr('href'),
tracked = specific_tracker._trackEvent('Downloads', 'PDF', dl_url);
if ( typeof console.log == 'function' ) console.log( specific_tracker._getName(), tracked, dl_url );
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment