wpcf7mailsent Not Firing; addEventListener Not Working
-
I’m working with Google Analytics, Google Tag Manager and Contact Form 7 to track events. I have the following script on the site:
<script> var wpcf7Form = document.querySelector( '.wpcf7' ); if (wpcf7Form){ wpcf7Form.addEventListener( 'wpcf7mailsent', function( event ) { dataLayer.push({'event' : 'Form Submitted'}); }, false ); } </script>
GA and GTM are also placed on the page in their appropriate places. No matter what, I can’t seem to get this to fire. I’m checking the variable because I was getting a null error.
I’ve taken a step back, and attempted to get a simple redirect to work with an on page script as well as via Additional Settings, but again, it doesn’t seem “wpcf7mailsent” is firing.
All forms DO work as far as displaying the thank you message and sending off the email.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wpcf7mailsent Not Firing; addEventListener Not Working’ is closed to new replies.