Skip to content

Instantly share code, notes, and snippets.

@cgrymala
Created Jul 31, 2013
Embed
What would you like to do?
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