Contact Form 7 is a popular contact form plugin used on WordPress. Many local businesses often turn to Contact Form 7 because of its robust and simplistic features, making it the ideal plugin for WordPress websites of all trades.
We’ve often been asked by our clients who run Google AdWords to implement Google AdWords conversion tracking. Conversion tracking allows business owners to measure the success of their campaign by tracking the number of successful leads which come through. It’s interesting to know that most WordPress contact forms actually don’t offer this as a default setting.
Many small hacks and plugins often don’t work in fixing this problem. In this post, I’ll explain and thoroughly go through the steps needed to successfully implement Google AdWords conversion tracking with Contact Form 7.
1. Google Adwords Conversion Tracking Code
Login to your Google AdWords campaign and have your conversion tracking code on standby. Your tracking code which should look something like this:
<!– Google Code for Conversion Page –>
/* <![CDATA[ */
var google_conversion_id = XXXXXXXXX;
var google_conversion_language = “en”;
var google_conversion_format = “3”;
var google_conversion_color = “ffffff”;
var google_conversion_label = “XXXXXXXXXXXXXXXXXXXX”;
var google_remarketing_only = false;
/* ]]> */
<img height=”1″ width=”1″ style=”border-style:none;” alt=”” src=”//www.googleadservices.com/pagead/conversion/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”/>
2. Create “Thank You” Page
Create a thank you page you’d like your prospects to be redirected to after they’ve successfully sent their enquiry. The thank you page will be where your conversion tracking code will be located.
Fill the page with a simple and polite thank you message, acknowledging you’ve received their enquiry. For your convenience I’ve included a generic message which you can simply copy and paste.
Thank you for contacting us. We’ve received your enquiry and one of our friendly staff members will be in touch with you shortly.
3. Install Smart Google Analytics Code Plugin
On the left hand side of the WordPress admin interface, install and activate Smart Google Analytics Code. Click onto the plugin settings and scroll towards the bottom of the page where you will find the conversion code settings. Paste in your Google AdWords conversion code into the right-hand box and select the thank you page you previously created. Conversion name can be anything you’d like.
Once complete, hit “Save AdWords”.
4. Add Function Command To Functions.php
To do this, insert the following code into your theme’s functions.php. To locate the file, navigate your way to Appearance > Editor > Theme Functions (functions.php). Paste in the code below.
$on_sent_ok = $wpcf7 >additional_setting(‘ip_on_sent_ok’, false);
if (is_array($on_sent_ok) && count($on_sent_ok) > 0)
5. Add Redirect Command To Form Settings
Make your way to your chosen contact form. Scroll down towards the bottom where you will find the option Additional Settings. Paste in the following code:
Edit the above URL to your own. Credits go to maryisead.
Find the following:
define( ‘WPCF7_LOAD_JS’, true );
And replace it with:
define( ‘WPCF7_LOAD_JS’, false );