问题
I`m trying to track submitted contact forms in google analytics with contact form 7. I tried the following:
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...
...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.
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