Google Analytics Goal setting in Contact Form 7Raj
I came across this technical challenge of setting Google Analytics goal with contact form 7 plugin.
I browsed many forums and finally derived a solution – though it would be useful for any one struggling with it.
In Google Analytics account:
Go to Admin >> Goals and start setting up goal (obviously to track contact form submissions).
In ‘Create a Goal’, select ‘Custom’. Input some suitable name and select ‘Destination’ radio button.
Now, in destination, specify some fake URL like ‘thankyou.html’ which is non-existing page on the domain.
Then, go to contact form 7 settings. Now, scroll down to the specific form set up page.
In ‘Advanced Settings’ section, input this code:
on_sent_ok: “_gaq.push([‘_trackPageview’, ‘/thankyou.html’]);”
Here, ‘thankyou.html’ is taken for example. Please be careful that the URL you use, is consistent in Google Analytics goal set up and contact form 7 setting.
Now, you may do a trial submission of the form and see it tracked as ‘Goal’!!!!!