Contact form 7 - Google Analytics Tracking

我只是一个虾纸丫 提交于 2019-12-11 17:54:34

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/46170043/contact-form-7-google-analytics-tracking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!