Skip to content

Instantly share code, notes, and snippets.

@bavington
Last active November 23, 2017 14:40
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 bavington/4761a4e3fdd2e4cc667f2c38f7477b92 to your computer and use it in GitHub Desktop.
Save bavington/4761a4e3fdd2e4cc667f2c38f7477b92 to your computer and use it in GitHub Desktop.
Contact Form 7 (CF7) Event Handler GTM Data Layer Event Push
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
dataLayer.push({'event': 'cf7.contact-page.mailsent', 'cf7.formID': event.detail.contactFormId});
}, false );
</script>
@bavington
Copy link
Author

Update: The Event Handler has now been modified to carry a second variable (CF7 Form ID), in order to track events for multiple forms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment