If you use Google Analytics to analyze web traffic on your site, I imagine you would like to track submissions through your contact forms as well. Contact Form 7 allows you to set up this type of tracking very simply. In this post, I’ll show you how to do it.
If you’ve set everything up correctly, Contact Form 7′s contact form behaves as an Ajax application and its form submission is an Ajax event. Google Analytics’
_trackEvent() method is able to track an Ajax event without a real page view or redirection.
For example, let’s say that the name of your page tracker object is
_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);
on_sent_ok action hook
It is quite a straightforward process for you to specify the aforementioned
_trackEvent() with the
on_sent_ok hook. You will find the Additional Settings field at the bottom of the contact form management page; now simply insert the following line into it:
on_sent_ok: "_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);"
Note that you need to quote the codes properly and the code must be in one line.
Now, if you have set everything up correctly, when someone makes a submission via your contact form, Google Analytics will track it as an event with Contact Form as the Category, and Submit as the Action.
To verify that this is working correctly, you can check the Content > Events > Overview report page on Google Analytics 24-48 hours after a submission. At that point, you should be able to find the Contact Form category there.
- Contact Form 7 WP – How to Add Event Tracking on New Universal Google Analytics | Astral Web Blog
If you use this with the latest Universal Analytics.