Location: SMB SEO Guide > Blog > Thesis > AdWords Conversion Tracking with Thesis

AdWords Conversion Tracking with Thesis

Thesis for WordPress

You know it’s important to have an SEO-friendly content management system, and WordPress is my favorite CMS for most small business websites. Recently I’ve been using the Thesis theme for WordPress for most web design projects, and I’d be hard-pressed to launch a new site with anything else. In fact, this site is built on Thesis.

Thesis is well-optimized out-of-the-box and you can easily customize your blog design with just a few clicks of the mouse. It’s a no-brainer purchase if you’re looking to redesign or start a new website. That being said, there are times when you want to make some customizations outside the scope of the Thesis design interface. In these cases, you’ll need to use the custom_functions.php file. Sounds scary, I know, but it’s not so bad once you’ve used it a few times.

One function not provided out-of-the-box (yet) is easy integration of your PPC conversion code. But this can be easily fixed using a custom function.

Here’s an example. Let’s say I want to track how many people sign up for my free Small Business SEO lessons via AdWords. I would put the following code in my custom_functions.php file:

function insert_tracking_code() { ?>
<?php if (is_page('Thank You for Subscribing')) { ?>
<!-- Google Code for SEO-O Small Biz Lessons Conversion Page -->
<script type="text/javascript">
<!--
var google_conversion_id = xxxxxxxxxx;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "yyyyyyyyyyyyyyyyyyyy";
var google_conversion_value = 0;
//-->
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/xxxxxxxxxx/?label=yyyyyyyyyyyyyyyyyyyy&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
<?php } ?>
<?php }
add_action('thesis_hook_after_html', 'insert_tracking_code');

So let’s break this down into a generic code snippet you can use on your own website:

function insert_tracking_code() { ?>
<?php if (is_page('The Name of Your Conversion Page')) { ?>
<!-- Insert Google Code for Your Website Conversion Page Here -->
<?php } ?>
<?php }
add_action('thesis_hook_after_html', 'insert_tracking_code');

First, we defined what we wanted to do by making a function called insert_tracking_code. We said that if someone was on a page called [whatever you named your conversion page], then go ahead and execute the Google AdWords conversion code (you could also throw in Yahoo! and MSN conversion codes if you’d like).

Next, we used add_action to tell our server where to execute that function

  1. The first part of the add_action directive is the where (thesis_hook_after_html is a Thesis-specific hook that tells the server to place the code just before the </body>)
  2. The second part of add_action is the what – execute the insert_tracking_code function, which we just defined above

So there you have it. Now you can easily implement conversion code on your site without hacking the WordPress core.

Bookmark and Share

{ 1 trackback }

Thesis Custom Function: Change the Subscribe Link — SMB SEO Guide
August 18, 2010 at 3:08 pm

{ 5 comments… read them below or add one }

Jenny December 31, 2009 at 2:43 am

Hello, I have added the code into the custom_functions.php to track conversions on the Transaction Results page which is the page the customer returns to after paying with Paypal. I purchased a test product and no conversion has shown up in Adwords.

When I copied and pasted the code from adwords and added the additional hooks it all went on one line in custom_functions.php – I wondered why this happened and if this could be the problem.

Any help would be appreciated.

Have you any ideas as to what might be wrong.

Reply

Jenny December 31, 2009 at 3:35 am

Still attemptin to find out why conversion tracking is not working. My tracking page is Transaction Results although the full address is domain/product-page/transaction-results – Do I need to put product-page/transaction-results in the page name?

Reply

admin January 1, 2010 at 12:20 pm

Hi Jenny,

Looking at the source code of http://www.readscreations.co.uk/products-page/transaction-results/, I do see the conversion tracking code, so it appears the custom function worked properly.

When you did the test order, did you click through from an AdWords ad?

Remember, this code will only count conversions for AdWords PPC advertising. You would also need additional code for Yahoo and MSN PPC if you’re advertising on those networks as well.

PS – Happy New Year!

Reply

lux July 27, 2010 at 6:49 am

Hi, John,

Will you be so kind to make a screencast for this?

It may seem super easy for you but it’s all gibberish to a noob. =)

All I want is to add the tracking code to my converting page. And your insight is the closest to the solution I am looking for.

Your assistance will be much appreciated.

Thanks.

Lux

Reply

admin August 18, 2010 at 3:57 pm

Hi Lux,

I probably won’t have a chance to make a screencast any time soon, but I think it’s a great idea – I’ll keep it in mind for a future post. In the meantime, let me see if I can make the process a bit easier to understand (I probably left out a few important steps above).

  1. Generate your conversion code in AdWords or AdCenter or whatever program you’re trying to track. Keep this code handy for later on.
  2. Create your confirmation page in WordPress – make sure it’s a page, not a post. For this example, we’ll assume you title the page “Thank You.”
  3. Go to your Custom Functions file – this will be found in the Thesis menu in your WordPress admin. Click on “Custom File Editor” in the sidebar. Then select “custom_functions.php” from the drop down and click the “Edit selected file” button.
  4. Now that you’re in the right place, it’s time to add the code. Copy the highlighted generic code snippet above exactly as you see it and paste it into the custom_functions.php file. Replace “The Name of Your Conversion Page” with the actual name of your conversion page – “Thank You” is what we’re using in this example. Next, replace “< !– Insert Google Code for Your Website Conversion Page Here –>” with your conversion code from step one.
  5. Say a prayer and click the save button

Reply

Leave a Comment

Spam Protection by WP-SpamFree

Previous post:

Next post: