Skip to content

Instantly share code, notes, and snippets.

@maxxcrawford
Created October 5, 2016 16:23
Show Gist options
  • Save maxxcrawford/71cb27a94718e944c2517ec9d238d6c7 to your computer and use it in GitHub Desktop.
Save maxxcrawford/71cb27a94718e944c2517ec9d238d6c7 to your computer and use it in GitHub Desktop.
Fire a GTM dataLayer event on form submission using Parsley.js validation
// GTM Parsley Fire
if ( $('.rsvp-content form').length ){
$('.rsvp-content form').parsley().on('form:submit', function() {
// This global callback will be called for any field that fails validation.
// console.log( 'parsleySubmit' );
if (typeof dataLayer !== 'undefined') {
dataLayer.push({
"event": "form",
"section": "rsvp_submission"
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment