Last active
January 29, 2019 08:22
-
-
Save EmilEriksen/b7d492229aa658439ce3 to your computer and use it in GitHub Desktop.
Add event tracking to Ninja Forms submit
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
add_action( 'ninja_forms_display_js', 'prefix_track_form_submission' ); | |
function prefix_track_form_submission() { | |
?> | |
<script> | |
//<![CDATA[ | |
$( '.ninja-forms-form' ).on( 'submitResponse', function( e, response ) { | |
var errors = response.errors; | |
if ( errors == false ) { | |
// This is where you put the tracking code. This only fires if form submission is successfull | |
_gaq.push(['_trackEvent', 'Contact Form-Send', 'Click']); | |
} | |
}); | |
//]]> | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment