Warning: include(/home/customer/www/webholism.com/public_html/wp-content/plugins/sfwd-lms/vendor/composer/../psr/container/src/ContainerInterface.php): failed to open stream: No such file or directory in /home/customer/www/webholism.com/public_html/wp-content/plugins/better-wp-security/vendor-prod/composer/ClassLoader.php on line 576

Warning: include(): Failed opening '/home/customer/www/webholism.com/public_html/wp-content/plugins/sfwd-lms/vendor/composer/../psr/container/src/ContainerInterface.php' for inclusion (include_path='.:/usr/local/php74/pear') in /home/customer/www/webholism.com/public_html/wp-content/plugins/better-wp-security/vendor-prod/composer/ClassLoader.php on line 576
How to Add AdWords Conversion Tracking to Contact Form 7 in WordPress
Skip to main content

How to Add AdWords Conversion Tracking to Contact Form 7 in WordPress

Google Adwords Logo

Well, we never thought that adding an AdWords conversion tracking code to a Contact Form 7 form in WordPress would be the ridiculous polava it turned out to be.

To cut a long story short, WordPress gets funny about scripts on WordPress pages, and the AdWords code unfortunately falls into such a category.

You also need to make sure the code gets in-between the <body> </body> tags, otherwise it won’t register with AdWords.

To save you time and grey hair, here’s the quick fix:

  1. Create a thank you page (this should be a normal page from the Pages -> Add New menu item), and set the permalink to “thank-you” (or something similar, which will be used below).
  2. Create your Contact Form 7 form, and in the “Additional Settings” box at the very bottom, put: on_sent_ok: “location.replace(‘http://YourDomain.com/thank-you/’);”
  3. Go to Plugins -> Add New.
  4. Search for and install the Smart Google Analytics Code plugin.  Activate plugin.
  5. Click the Smart Google Code option from the main side menu on the left.
  6. Add your AdWords tracking code to the AdWords Conversion Code Settings box at the bottom, pick your newly created Thank You page from the drop down list and complete the Caption box with something meaningful.
  7. Save Changes, run a test form submission, check the thank you page source code (right click -> view source code) to check the AdWords conversion tracking code is showing in-between the <body> tags.

Note: It can take up to 48 hours for customers who click your AdWords advert and then “convert”, to appear in your AdWords statistics.

Troubleshooting

  • If your form does not send when you push the send button, you might be experiencing an “Uncaught SyntaxError: Unexpected token ILLEGAL” error when your form is submitted (error will not show on the page, and will only show as an error when you open the Inspect Element or Console part of Chrome).  To resolve this, please make sure any code you copy from this article, (or from the Google AdWords conversion code section) is pasted into a plain text editor first to remove any formatting (use Notepad for PC’s, or TextEdit in plain text mode for Mac’s).  This seems to be a problem with Chrome browsers in particular.

Sara Thornton

Sara is WebHolism's SEO Guide and Trainer. She's the one you'll see in all our YouTube videos, and helping folks out with their SEO queries on social media. She runs the fabulous SEO Clarity Club which teaches women how to do their own SEO. In her spare time she loves board games, and splashing around in the sea.

Comments (20)

Leave a Reply

Your email address will not be published. Required fields are marked *