Created
October 5, 2016 16:23
-
-
Save maxxcrawford/71cb27a94718e944c2517ec9d238d6c7 to your computer and use it in GitHub Desktop.
Fire a GTM dataLayer event on form submission using Parsley.js validation
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
// 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