Tracking form submissions in Google Analytics is easy to set up in Contact Form 7 in WordPress. You can do so without setting up additional thank you pages which saves you the trouble of creating additional content you don’t really need. I use Contact Form 7 on this site and have used it in other places, and this question has come up more than once. I decided I’d show you how I do it which can be done with a single line of code.
For the purpose of this exercise I’m assuming you’ve installed the latest GA code to date (March 28, 2012), and you’ve installed Contact Form 7 so that AJAX will work properly.
Google has made it very simple to track virtual page views when you have specific content you’d like to view. This is especially useful when you have data-driven websites or event states such as form submissions. I use this to track successful form submissions.
_gaq.push(['_trackPageview', '/contact/thank-you/']);
Note: This is the latest GA code as of 3/28/2012.
Using Additional Settings
Contact Form 7 provides a text field titled Additional Settings in which you can provide code and other instructions on what to do on an individual form when submitted. For the purpose of tracking successful form submissions, we’re going to use the on_sent_ok hook. Now we know the virtual page we’re tracking we can add the following line to Additional Settings:
on_sent_ok: "_gaq.push(['_trackPageview', '/contact/thank-you/']);"
Check Your Analytics Account
Assuming everything has been set up properly, when you check your analytics account you should see /contact/thank-you/ in the Content Overview section. This virtual page will not show up unless someone has filled out your form without error and submitted it.
That’s it!




