How To Use Google Conversion Tracking In Wordpress

Conversion tracking is a major part of a successful online marketing campaign. Tracking lets you know how effective your website and sales funnel are at persuading visitors to take a desired action.

With this information, you can do a lot.

AdWords Conversion Tracking

Google AdWords Conversion Tracking Tool

Let’s say you have a form on your Wordpress site that sends users to a ‘Thank You’ page after they fill it out, which isn’t linked to from anywhere else on your site. The only way they can reach this page is by filling out the form. By placing AdWords conversion tracking on that page, you can see exactly which keywords people searched for who ended up clicking on your ad and filling out your form.

From here on out, anyone who fills out the form is counted as a successful lead conversion by AdWords, allowing you to go into your reports and see what keywords are creating value for your business. You then can take a number of actions: up your cost-per-click bid on keywords that are converting, create SEO campaigns around those keywords, build out additional products/services around those keywords, etc.

You can see how powerful this is.

Wordpress

Wordpress is my favorite content management system (CMS) for building websites. It’s free, easy, and you can get up and running very fast. I’ll get more into why I love Wordpress in a later post, but for now, let’s take the above example and assume you have a form on a Wordpress site that you’d like to start tracking with Google Conversion Tracking.

Seems simple enough, right? Just copy and paste Google’s conversion tracking code onto the ‘Thank You’ Wordpress page. But there’s a problem — Google’s tracking code is written in a language called Javascript, and Wordpress doesn’t like it when you place Javascript inside pages.

However, Javascript plays fine with Wordpress when you place it within the template files themselves. For example, you can place any type of Javascript code at the bottom of your theme’s footer.php and everything will work great.

But when it comes to conversion tracking, we can’t just put the code in the footer because it would be loaded with every page on your site and count a visit to any page as a conversion.

I outline two solutions below. The first is the preferred method, with an alternative method to follow.

Preferred method: Create a custom Wordpress page template for your ‘Thank You’ page that includes the tracking code.

Here are the steps:

1. Using an FTP client, log-in to where your Wordpress site is hosted. Navigate to /wp-content/themes/yourtheme, with ‘yourtheme’ being the name of the active theme on your site.

2. Download page.php and open it in your favorite HTML editor. Then, place this code at the very top of the page:

<?php 
/*
Template Name: Thanks
*/
?>

3. At the bottom of the page, paste your Google Conversion Tracking code right before this tag:

</body>

4. Save the file as thanks.php and using your FTP client, upload it to your /wp-content/themes/yourtheme/ folder.

5. Log in to your Wordpress admin panel and Edit the ‘Thank You’ page. On the right-hand side of this screen, under Attributes you should now see a Template drop-down box. Click the box and select Thanks.

Custom Template

6. Click Update Page and you’re done!

Alternative method: Create a copy of your ‘Thank You’ page and save it as it’s own PHP file with Google’s conversion tracking code placed at the bottom of it.

Here are the steps:

1. Navigate to your site’s ‘Thank You’ page in your web browser and select View Source Code. (In Internet Explorer, click View > Source from the drop-down menu. In Firefox, click View > Page Source).

View Source
2. Copy and paste all of the source code to a new file in your favorite HTML editor. You can do this by right-clicking anywhere in the source code and clicking Select All, then right-clicking again and clicking Copy.

3. Within your HTML editor, paste your page’s source code. Then, paste the Google Conversion Tracking Code at the bottom, right above

</body>

4. Save the file as thank-you.php.

5. Connect to your website with your favorite FTP client and upload the file to your website’s root directory. (Note: your root directory is most likely the first folder that your FTP client takes you to when you connect. If you see another folder named wp-content, you are in the right directory.)

6. Test your page and make sure it loads and all of your links work correctly by going to http://www.yoursite.com/thank-you.php.

7. Set your form’s ‘Thank You’ page to point to http://www.yoursite.com/thank-you.php.

You’re done! This will work with both Google AdWords and Google Analytics conversion tracking. If you have any questions, please post them in the comments.

Related posts:

  1. How To Turn Any Link Into A Google Analytics Goal
  2. How To Track Form Submissions With Google Analytics Goals



21 Responses to “How To Use Google Conversion Tracking In Wordpress”

  1. Jayna says:

    Thanks for this detailed tutorial, John! I was trying to find a way to track the conversion rate on my website, but couldn’t figure how to integrate Google’s conversion tracking with Word Press. Thanks to your helpful information, though, I’m good to go. Awesome information and much appreciated. Thanks!

  2. Jayna,

    Glad I could help! Thanks for the comment.

  3. [...] the act of filling it out into a “conversion” goal for Adwords conversion tracking (How to Use Google Conversion Tracking in Wordpress) or Google Analytics (How to Track Form Submissions With Google Analytics [...]

  4. Jimmy says:

    Nice read, I think I am there but I am getting a “binary transfer error” when uploading with my FTP client, could anyone advise on this?

  5. Hey Jimmy,

    What FTP client are you using? I know of problems with using Internet Explorer for uploading files.

  6. Rob says:

    Hello Jimmy,

    I did as you said. A pasted the google tracking code at the bottom of the page.php and saved it ask thanks.php uploaded it and activated it on the thank you page. When I view the source code it shows up outside the body at the bottom of the source code. There was not a body tage in the pages.php file that I downloaded. How do I know where to place the code?
    Thanks,
    sunrisecustomfence.com/thank_you please take a look.

  7. Hey Rob,

    I just took a look at your page and am seeing the conversion tracking code placed correctly.

    Are you using Google Adwords conversion tracking, or Google Analytics goal tracking? If you’re using Adwords tracking, are you currently running Adwords campaigns? I did some quick research on your domain and don’t see that you have any Adwords ads currently running.

    Let me know, I’m happy to help.

    John

  8. John – many thanks for your method!
    One question though: will we have to repeat this procedure every time we upgrade WP or the Theme?

  9. Yo Tango,

    No problem. To answer your question, you will have to repeat every time you upgrade your theme, but you should be fine when upgrading Wordpress.

  10. Thanks. BTW, I couldn’t find page.php file (might be a “feature” of the theme?), and opted for your alternative method. Worked fine. Now I think that because of the location of the thanks.php it might not be affected by either WP or theme update.
    Does it make sense?

  11. Tango,

    Sorry for the delayed response — Correct. If your ‘thanks.php’ file is in your root folder, you should be fine. Have you gotten it to work?

  12. Indikas says:

    Hi John,
    Thank you for a informative post. Can you please clarify step 7.

    Is it just hyperlinking http://www.yoursite.com/thank-you.php from one of the wp page that you consider to be the thank you page?

    Appreciate if you could clarify this.

    BTW; if I were to use your first method, is it possible ad the tracking code to an existing template, i.e. modify the template_1.php and add the tracking code to the bottom of it?
    Cheers
    Indikas

  13. Indikas,

    Step 7 means setting your form’s ‘thank you’ page to http://www.yoursite.com/thank-you.php. This will probably be done within your chosen form software. Check out the settings for your form and look for where you can specify your own ‘thank you’ page. If you’re having trouble, let me know.

    For your second question, yes, you can add the code to the bottom of your existing template, but you want to be careful that that template is only used for your ‘thank you’ page. For instance, you wouldn’t want to add it to the bottom of page.php and have it show up on every page of your site, otherwise you will get false positives.

    Hope I answered your questions!

  14. Indikas says:

    Hi John,
    Thanks for the feedback. I’m quite new to web development and wordpress and not familiar with some of the terminology.

    I’m just working on my first project at the moment, and it is quite exciting to learn all these new things. I’m using Wordpress in my site,
    http://www.becomeapilotonabudget.co.uk/

    and my “thank you” page is accessed as http://www.becomeapilotonabudget.co.uk/thankyou/

    Sorry for being ignorant, but what is a form in relation to worpress. I know about posts and pages in wordpress, but not forms.

    I added my thankyou page to my site by going to page->add new….

    I’m using the default theme with a free template that I managed to find on the web.

    Still I do not understand what you mean by “Step 7 means setting your form’s ‘thank you’ page to http://www.yoursite.com/thank-you.php

    Are you refering to the autoresponder form’s redirect link?
    i.e. to replace the following

    with

    Appreciate your comments.

    Cheers

    Indikas

  15. Indikas,

    Exactly, set your autoresponder form’s redirect link to point to yoursite.com/thank-you.php.

    Of course, this is after you’ve followed steps 1-6. :)

  16. kunal says:

    Thanks for the walkthrough. What if I want to track the users that come through adwords and register on my wordpress website? Is there a way to add the code to the wordpress registration page only after the users register?

  17. joe says:

    John thanks for the tips. It seems as if crucial parts of this post have gone missing. I can’t tell where to post the google code in the thankyou.php file.

    That part of the post appears to be gone.

    Thanks for the help!

    -Joe

  18. Kunal,

    Sorry for the delay – I’ve never used Wordpress’s ‘register’ feature — what page does it send users to once they register?

  19. Joe, thanks for the tip. Just fixed it. Let me know if you have any questions!

  20. TP says:

    Hi John,

    While I get the thank you page etc., just like we would do in other web apps.

    My question here is about the custom redirection upon successful submission of the form.

    I am using a basic WP theme, and I am not aware how to redirect the form post submission to a thank you page.

    Is there a specific plugin available?

    PS – I have always used Contact Form Plugin for Wordpress.

    Many thanks.

  21. TP, what page are users sent to after completing the form? There should be an option in the settings for your Contact Form plugin that allow you to set a custom thank you page.

Leave a Reply

SEO Powered by Platinum SEO from Techblissonline