Created
November 30, 2016 10:54
-
-
Save level09/5b6809836f38826b2843ff6f48f0f3b1 to your computer and use it in GitHub Desktop.
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
(function($){ | |
$(window).load(function() { | |
//Track Downloads | |
$('a').filter(function() { | |
return this.href.match(/.*\.(zip|mp3*|mpe*g|pdf|docx*|pptx*|xlsx*|rar*)(\?.*)?$/); | |
}).click(function(e) { | |
ga('send','event', 'download', 'click', this.href); | |
}); | |
//Track Mailto | |
$('a[href^="mailto"]').click(function(e) { | |
ga('send','event', 'email', 'send', this.href); | |
}); | |
//Track Outbound Links | |
$('a[href^="http"]').filter(function() { | |
if (!this.href.match(/.*\.(zip|mp3*|mpe*g|pdf|docx*|pptx*|xlsx*|rar*)(\?.*)?$/)){ | |
if (this.href.indexOf('thisisyoke.com') == -1) return this.href; | |
} | |
}).click(function(e) { | |
ga('send','event', 'outbound', 'click', this.href); | |
}); | |
//Track Affiliates | |
$('a').filter(function() { | |
if ('/out/'!=''){ | |
return this.href.match(/(\/out\/)/); | |
} | |
}).click(function(event) { | |
ga('send','event', 'affiliates', 'click', this.href); | |
}); | |
}); | |
})(jQuery); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment