Skip to content

Instantly share code, notes, and snippets.

@azend
Created July 23, 2013 15:23
Show Gist options
  • Save azend/6063249 to your computer and use it in GitHub Desktop.
Save azend/6063249 to your computer and use it in GitHub Desktop.
jQuery Mobile GA link tracking
$('a').on('click', function (e) {
// jQuery Mobile uses anchor tags for slider handles...
//
// Using the following is less eloquent than using :not()
// but it is browser compliant.
if ( !$(this).hasClass('ui-slider-handle') ) {
var external = this.target === '_blank' || this.rel === 'external';
if ( external ) e.preventDefault();
// Run your GA tracking code here...
if ( external ) window.location.href = this.href;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment