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:
- 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).
- 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/’);”
- Go to Plugins -> Add New.
- Search for and install the Smart Google Analytics Code plugin. Activate plugin.
- Click the Smart Google Code option from the main side menu on the left.
- 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.
- 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.
- 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.