My code looks liket this:
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
window.dataLayer.push({
“event” : “cf7emailsent”,
“cf7FormId” : event.detail.contactFormId,
})
});
Or is there a way in JS to get the form object including my custom form property with the form id (detail.contactFormId)?
]]>Here is the script:
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
location = ‘https://hidrogood.com.br/orcamento-obrigado-por-sua-solicitacao’;
}, false );
]]>Thanks
]]>Great plugin. We are trying to track the Contact Form 7 forms that are correctly sent.
With the original Pixel Code we track it like this:
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
fbq('track', 'Lead');
}, false );
</script>
We have noticed that you don’t use the function fbq
so that this code is not working with your plugin.
Which would be the equivalent to fbq('track', 'Lead');
with your plugin?
Thanks for your help.
]]>$form.submit( function( event ) {
if ( typeof window.FormData !== 'function' ) {
return;
wpcf7.submit( $form );
}
window.FormData is an object on iOS 8 and older so the form wasn’t calling wpcf7.submit
.
I hope this can be fixed one way or another. For those looking for a temporary solution, I used a polyfill for FormData: https://github.com/jimmywarting/FormData
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '2187' == event.detail.contactFormId ) {
location = 'https://www.mydomain.com/thank-contacting-us/';
}
}, false );
</script>
to redirect after sent.
after using your plugin redirect to a page after sent not working anymore, what i need to change?
i have try to on/off “Send CF7 mail as usually” but is the same.
thanks
]]>This seems to be a widespread issue.
Has anyone resolved this problem?
If I use on_sent_ok on the same form, will it clash with addEventListener?
]]>
<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.
]]>