-
-
Save cgrymala/8eb9128181705b72bb0a to your computer and use it in GitHub Desktop.
Track UMW home page clicks
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
// Track other home page clicks | |
if ( jQuery( 'body.network-www.site-root.home' ).length > 0 ) { | |
jQuery( '#home-middle a[href!="#"]' ).each( function() { | |
var tmpAction = jQuery( this ).closest( '.widget' ).find( '.widgettitle' ).text(); | |
var tmpLabel = jQuery( this ).text(); | |
if ( tmpLabel == '' && jQuery( this ).find( 'img' ).length > 0 ) { | |
if ( jQuery( this ).closest( '.post' ).length > 0 ) { | |
tmpLabel = jQuery( this ).closest( '.post' ).find( 'h2' ).text(); | |
} else { | |
tmpLabel = jQuery( this ).find( 'img' ).attr( 'alt' ); | |
} | |
} | |
jQuery( this ) | |
.attr( 'analytics-category', 'Home Page Links' ) | |
.attr( 'analytics-action', tmpAction ) | |
.attr( 'analytics-label', tmpLabel ); | |
jQuery( this ).one( 'click', function() { | |
_gat._getTrackerByName()._trackEvent( | |
jQuery( this ).attr( 'analytics-category' ), | |
jQuery( this ).attr( 'analytics-action' ), | |
jQuery( this ).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