Skip to content

Instantly share code, notes, and snippets.

@klhall1987
Last active April 15, 2020 18:17
Show Gist options
  • Save klhall1987/2c8f4a363636bf71a593c580d49eda83 to your computer and use it in GitHub Desktop.
Save klhall1987/2c8f4a363636bf71a593c580d49eda83 to your computer and use it in GitHub Desktop.
Example of how to use the .on formSubmit listener.
<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>
@sohaibgondal
Copy link

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');
}
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment