Contact Form 7 -> Google Tag Manager Event

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

Hello @aleadfreak,

Thanks for asking. Please note that the problem is not related with X or Pro. In that regards it’s outside the scope of the support we offer. However you can refer following articles to get started:



Thanks for understanding.