Created
July 23, 2013 15:23
-
-
Save azend/6063249 to your computer and use it in GitHub Desktop.
jQuery Mobile GA link tracking
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
$('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