Skip to content

Instantly share code, notes, and snippets.

@Macuzzin
Last active April 5, 2018 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Macuzzin/b958a53464580316cd6627ac6e0aa5eb to your computer and use it in GitHub Desktop.
Save Macuzzin/b958a53464580316cd6627ac6e0aa5eb to your computer and use it in GitHub Desktop.
Data Layer Push Event for Tracking Contact Form 7 Submissions from Different Forms with Google Tag Manager
<script>
// CF7 Submit Trigger
document.addEventListener( 'wpcf7mailsent', function( event ) {
if("311" == event.detail.contactFormId) {
dataLayer.push({'event': 'Contact Form Submitted'});
} else if ("842" == event.detail.contactFormId) {
dataLayer.push({'event': 'R500 OFF Form Submitted'});
}
}, false );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment