-
-
Save albertpak/8894205 to your computer and use it in GitHub Desktop.
Simply paste this snippet into your document ready block to get started, then on any links you'd like to track, simply provide the data-mixpanel-tracker attribute: Specify custom properties in JSON using the data-mixpanel-properties attribute: <a href="/moon" data-mixpanel-tracker="he chose to go to the moon" data-mixpanel-properties="{agency: '…
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[data-mixpanel-tracker]').click -> | |
setTimeout (=> window.location.href = $(@).attr('href')), 300 | |
tracker = $(@).attr('data-mixpanel-tracker') | |
properties = JSON.parse($(@).attr('data-mixpanel-properties') || '{}') | |
mixpanel.track tracker, properties | |
return false |
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[data-mixpanel-tracker]').click(function() { | |
var properties, tracker; | |
setTimeout(((function(_this) { | |
return function() { | |
return window.location.href = $(_this).attr('href'); | |
}; | |
})(this)), 300); | |
tracker = $(this).attr('data-mixpanel-tracker'); | |
properties = JSON.parse($(this).attr('data-mixpanel-properties') || '{}'); | |
mixpanel.track(tracker, properties); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment