Skip to content

Instantly share code, notes, and snippets.

@cgrymala
Created July 31, 2013 15:42
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 cgrymala/9cb63973c4b0f6694f50 to your computer and use it in GitHub Desktop.
Save cgrymala/9cb63973c4b0f6694f50 to your computer and use it in GitHub Desktop.
Track slideshow clicks and slide order
document.body.onload = function() {
jQuery( '.slides .slide' ).each( function() {
var tmpAction = jQuery( this ).find( 'h1' ).text();
var tmpLabel = 'Slide #' + jQuery( this ).index();
jQuery( this )
.attr( 'analytics-category', 'Home Page Slideshow' )
.attr( 'analytics-action', tmpAction )
.attr( 'analytics-label', tmpLabel );
jQuery( this ).find( 'a' ).one( 'click', function() {
_gat._getTrackerByName()._trackEvent(
jQuery( this ).closest( '.slide' ).attr( 'analytics-category' ),
jQuery( this ).closest( '.slide' ).attr( 'analytics-action' ),
jQuery( this ).closest( '.slide' ).attr( 'analytics-label' ),
1,
true
);
setTimeout( 'document.location="' + jQuery( this ).attr( 'href' ) + '"', 100 );
return false;
} );
} );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment