Best way to add Adwords Conversion tracking code to WP?

Good timing on the WP forum!

I’ve been googling ways to add Adwords Conversion tracking code to WP and the best method so far seems to be to create a custom ‘thankyou’ page with the conversion tracking code on it and redirect the contact form to it. I’d prefer the code to be on the actual contact page though, you get a few more false positives that way but you’ll also pick up people who only wanted the phone number instead of just the poeple who email.

Seems a bit bodgy though, just wondering if any WP experts on here know a better way? In Joomla it would be as simple as creating a module and only allowing it to be active on the contact page, dead simple, can’t believe it’s not that easy with WP?

Can’t you just go into ‘html view’ when editing your contact page, and add the adwords conversion tracking code?
I never did it myself, but I took the tracking code from this site and added it to a test page, and it displayed perfectly fine in the html of the test page. Don’t know if that’s all there is to it though?

Hey Guido, thanks for your help. I’m not familiar with WP, if it’s that simple why are there so many people asking how to do it on Google and all the answers seem to be fairly convoluted?

I don’t know. You might give it a try :slight_smile:

Inserting the code directly into the HTML doesn’t work, if you try to do it with the WYSIWYG editor still active it just strips out half the code and if you disable the editor WP is wrapping some of the code in <p> tags and inserting <br> too which will most likely stop the code working as well as creating a bit of empty space on the page where the code is.

I’m going to try creating a new template containing the conversion tracking code which should be as simple as copying the defauilt template, giving it a new name using the PHP code below and it will then appear in the dropdown menu on the page itself and can be applied quite easily.


can you not set up two tracking codes:

First one goes on your contact page to monitor how many visits that page gets
Second one is in you “thanks” template, perhaps you could embed this template after successful form submission?

I’d be happy to get one tracking code working… It’s adding it to just one page on the client’s site that’s proving so difficult with Wordpress. Just that on it’s own makes me want to stay with Joomla.

I see what you’re saying though but it would make a bit of a mess of the PPC conversion stats if email conversions showed up twice in the summary tables. People starting on a PPC Ad and landing on the contact page would show as a conversion and if they then emailed using the form they’d show up again as a conversion.

How have you setup your contact page? If you’re using a plugin, you might be able to edit the code for the plugin itself, not the code for the contact page. Plugins > Installed > Edit (on the plugin).

Not sure that helps as I’ve not done this myself.

Ok, finally got it working I think. The lightbulb moment was when I realised that in creating a new template for WP I should have been copying and renaming the ‘page.php’ file (in the ‘wp-content/themes/default/’ directory) and not the ‘index.php’ file. Doh.

Copy the page.php file, rename it and insert the PHP snippet above as well as your conversion tracking code and assign it to the page you want to identify conversion for using the template drop down menu on the right hand side of WP.


Wouldn’t you use “Goals” to measure landing/completion pages? This might then give you a % of people who landed and completed the contact form (or not), so you could measure a success rate.

Goals are used more to track user paths through a site, if all you’re doing is creating a path that goes ‘some page-contact page’ then PPC stats do that equally well since it’ll tell me what keyword phrase generated the click and I know what the destination URL is for the Ad group.

If I create more complex Goals e.g. home-page - content page - contact page - thank you page’ then I get information about the IA of my site but it doesn’t add anything to my PPC conversion tracking where all I need to know is if the visitor started on a PPC Ad and ended up contacting my client.

JJ, modifying the templates is a quick and easy approach if you just have one or two pages to add the tracking code to.

The approach Guido mentioned and outlined here (disclosure - I authored the post) will let you add the tracking code on a per-page basis, using the custom fields available in WordPress:



Hey Wiz, yep very familiar with post, it ranks well for searches on this subject! As you say it’s a bit of a convoluted for me and my one page requirement.

I thought though that a change had been made to Optimiser that stopped your method from working? Sure I read that somewhere on a forum.