@gracy834
I got it. But I ran into a few more issues I wanted to recap in case someone else has a similar issue. So if I just use the script/code as is:
var wpcf7Elm = document.querySelector( '.wpcf7' );
wpcf7Elm.addEventListener( 'wpcf7mailsent', function( event ) {
dataLayer.push({'event' : 'Form Submitted'});
}, false );
…I get a “Uncaught TypeError: Cannot read property ‘addEventListener’ of null”.
And if I check it exists with an IF first…
var wpcf7Elm = document.querySelector( '.wpcf7' );
if(wpcf7Elm){
wpcf7Elm.addEventListener( 'wpcf7mailsent', function( event ) {
dataLayer.push({'event' : 'Form Submitted'});
}, false );
}
I squash that null error, but the dataLayer push isn’t firing.
So I went back to document…
document.addEventListener( 'wpcf7mailsent', function( event ) {
dataLayer.push({'event' : 'Form Submitted'});
}, false );
And that fired my GTM trigger. There’s a bit of a delay (maybe 3 minutes), but GA did finally register the event on today.