Skip to content

Instantly share code, notes, and snippets.

@cgrymala
Created July 31, 2013 16:11
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/8eb9128181705b72bb0a to your computer and use it in GitHub Desktop.
Save cgrymala/8eb9128181705b72bb0a to your computer and use it in GitHub Desktop.
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