![]()
This solution was taught to me by jameszol. Feel free to follow him on twitter.
Last week I was looking to set up conversion tracking for the WP e-commerce plug-in and I couldn’t find a anything that would help me. So I’ve taken it upon myself to help those who are looking to do this on their own.
I’m not going to go into why it’s important to have conversion tracking enabled on your site, if you’re looking to have it done you probably understand why it’s important.
(By the way, it doesn’t help that that the plug-in itself doesn’t have an admin section that allows you to simply paste your conversion tracking code)
Enough said, let’s get to it:
Step 1
Login to your Google Adwords Account
Click on the ‘Reporting‘ Tab, then ‘Conversions‘
Click the button that says, “New Conversion“
I’m not going to walk you through all the steps to get the code, but this will get you started on how to get access to the Google Adwords conversion tracking code. Once you have the code you can move on to step 2.
Step 2
Every plugin/checkout process has it’s own system for taking users through the checkout process. If you’re using the WordPress E-Commerce plugin than you can skip to step 3 now. If you’re not then step 2 is crucial.
Go into your analytics and find out what the URL is for when users get to the confirmation page. Usually it will be a regular expression, such as ‘sessionid=********’ and each expression will be unique. Here’s what mine looks like:
Your job is to find what your plugin/checkout process is using for it’s regular expression checkout confirmation page. Once you have that you can move to the next step.
Step 3
Open a notepad or dreamweaver file and paste the Google Adwords code that you received. Save the file as, ‘conv-codes.php’
Upload this file onto the root directory where your WordPress file are stored.
Step 4
Now comes the fun part! Go into your WordPress admin section:
Click on ‘Appearance” > ‘Editor‘
Click on your Footer file on the right side. Usually it’s ‘footer.php’
Some WordPress templates end their </body> and </html> in this file (and some don’t end them at all as was the case in my WordPress theme). Before the end of the </body> tag insert this code:
<?php if (stripos($_SERVER['REQUEST_URI'],'sessionid') !== false) {include 'conv-codes.php';} ?>
I’ll explain basically what this code does, if you don’t care then you can skip it. We’ve placed this code in a file that makes a regular appearance on every single one of your pages (a.k.a. your footer). But this php code is unique because it contains an if statement. IF the requested URI (web address) contains the words, ‘sessionid’ (or whatever your plugin/checkout process uses) then it inserts the code from your conv-codes.php file that you uploaded. And as we all know, that file contains the Google Adwords conversion tracking code they gave to us! So basically, this code will ONLY appear on the confirmation of sale page
That’s it! You now have a functioning conversion tracking system on your WordPress site. You can apply this same principle to any page as long as you know the unique web address expression. You’ll also have to set up a second conv-codes.php file if you’re tracking more than one conversion.
I hope this helps! Feel free to follow this blog, or email me at eli@semblem.com
{ 2 comments }






