Skip to content

Instantly share code, notes, and snippets.

@cgrymala
Created Jul 31, 2013
Embed
What would you like to do?
Track UMW home page clicks
// 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