Hi,
I’m looking to trigger an event in Google Tag Manager once the contact form 7 form on the site is submitted.
My Google Tag manager code is working, the code I used is:
// Add Google Tag Manager Code
// =============================================================================
function add_google_tag_manager_code(){
?>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WRDG6VL"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<?php
}
add_action( 'x_before_site_begin', 'add_google_tag_manager_code' );
// End Add Google Tag Manager Code
// =============================================================================
The event I am calling from Contact Form 7 is:
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
dataLayer.push({'event' : 'wpcf7successfulsubmit'});
}, false );
</script>
I’m not seeing any conversions when linking across to Google Analytics.
Can you help?
Thanks
Alex