-
-
Save cgrymala/9cb63973c4b0f6694f50 to your computer and use it in GitHub Desktop.
Track slideshow clicks and slide order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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