Last active
August 29, 2015 14:01
-
-
Save nitishn/3897a955a645a36d0173 to your computer and use it in GitHub Desktop.
Firing an analytics event on a link or form which changes the page sometimes causes the analytics event to be canceled. The proper way to handle this is to use a callback function like below.
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
var that = this; | |
event.preventDefault(); | |
var callback = function() { | |
$(that).parents('#nl_form').submit(); | |
} | |
_gaq.push(['_set','hitCallback', callback]); | |
_gaq.push(['_trackEvent', 'Newsletter Subscription', 'Started', window.location.pathname]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment