Last active
April 5, 2018 10:44
-
-
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
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
<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