Google analytics/Tag manager and Contact form submission
-
I tried to add a piece of Javascript to my page in order to trigger a function that would update Google Analytics that a WP Contact Form 7 was successfully submitted on my wordpress site using various tutorials i found on the net. First I added …
<script> document.addEventListener( 'wpcf7mailsent', function( event ) { ga('send', 'event', 'Contact Form', 'submit'); }, false ); </script>
However I got a “ga not defined error” in my JS debugger. So I decided to do the same thing except using Google Tag Manager – by adding…
<script> document.addEventListener( 'wpcf7mailsent', function( event ) { window.dataLayer.push({ "event" : "cf7submission", "formId" : event.detail.contactFormId, "response" : event.detail.inputs }) }); </script>
I created a custom HTML tag and triggered it on a Page View with containts URL ‘/contact/’ since URL ‘hahamarketing.com/contact/’ renders as ‘hahamarketingcom/contact’. (What’s that about BTW ?)
Problem is, when i enable the GTM manager debugger and click open my contact page with a hard refresh. The debugger doesn’t appear anywhere on the page..
Apparently it can take 48 hours for the event to propagate to my analytics interface so i really need to use the GTM debugger if possible. My web developer debugger doesn’t show any errors when i submit the form – so maybe that’s OK then ?
The page I need help with: [log in to see the link]
- The topic ‘Google analytics/Tag manager and Contact form submission’ is closed to new replies.