Last active
April 15, 2020 18:17
-
-
Save klhall1987/2c8f4a363636bf71a593c580d49eda83 to your computer and use it in GitHub Desktop.
Example of how to use the .on formSubmit listener.
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
<script> | |
jQuery( document ).ready( function() { | |
//Setup our on formSumbit Listener. | |
jQuery( document ).on( 'nfFormSubmitResponse', function() { | |
//Do Stuff | |
ga('send', 'event', 'Email List', 'Subscribed', 'New Subscriber'); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use simple if condition, to use form title as event label.
<script>jQuery(document).ready(function(){
jQuery(document).on('nfFormSubmitResponse', function(event, response, id){
if(response.id == '2'){
ga('create', 'UA-**********-*', {'name': 'gaCode'}); // optional in case if you need to specify the tracker.
ga('gaCode.send', 'event', 'NF submissions', 'Form Submitted', 'Enquire');
}
});
});