Created
July 6, 2013 15:47
-
-
Save lluchs/5940280 to your computer and use it in GitHub Desktop.
Tracks downloads via GA events.
This file contains hidden or 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
/* Downloads tracking */ | |
jQuery(function() { | |
var dlr = /\.(?!html?|php)(\w{1,4})$/ | |
jQuery('a').click(function() { | |
var m | |
if (typeof(ga) == 'function' && (m = dlr.exec(this.href))) { | |
ga('send', 'event', 'download', m[1], this.href) | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment