简体   繁体   中英

Contact form 7 - Google Analytics Tracking

I`m trying to track submitted contact forms in google analytics with contact form 7. I tried the following:

  1. I placed the code

    on_sent_ok: "ga('send', 'event', 'Contact Form', 'submit');"

in the additional settings. Does not work. This method is supported until the end of 2017. The new method is "DOM events", so...

  1. ...I tried it with DOM events. I placed the code

    <script> document.addEventListener( 'wpcf7mailsent', function( event ) { ga('send', 'event', 'Contact Form', 'submit'); }, false ); </script>

in the head of the template. Also, does not work.

  1. I also tried a WordPress plugin "Contact Form 7 Google Analytics" and this doesn´t work either. No matter which way I tried: The site doesn´t execute the line:

    ga('send', 'event', 'Contact Form', 'submit');

No event appears in the live view of google analytics. I had this problem a few months ago ( Wordpress and Google Analytics Events ) but this is a new site and i think it`s the same problem. There must be reason?

You can find the new site I am talking about here .

I am really happy about any help. Thank you!

Edit: New hint: After submitting a form there is no "thank you message". Nothing happens an the url changes to http://page.xyz/kontakt/#wpcf7-f4-p18-o1 I think this is not normal?

How did you set up event in google analytics? Maybe you need to pass a value in ga function.

在此处输入图片说明

If you set a value to 0 here and its "Greater than" selected, then you have to pass a value of '1' in ga send function.

You might want to try the Contact Form 7 Google Analytics Intelligence plugin, https://wordpress.org/plugins/cf7-intelligence . It automates the whole process including goal creation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM