Last active
August 29, 2015 14:03
-
-
Save 2get/5826f92761725d239dac to your computer and use it in GitHub Desktop.
analytics link track event ( hitCallback )
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
<!DOCTYPE html> | |
<script> | |
function trackEvent(self, category, action, label) { | |
var href = self.href; | |
ga('send', 'event', category, action, label, { 'hitCallback': | |
function() { | |
if (href) { | |
document.location = href; | |
} | |
} | |
}); | |
} | |
</script> | |
<a href="http://example.com" onclick="trackEvent(this, 'category', 'action', 'label'); return false;">LINK</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment