Shopp Analytics conversion tracking for Google Checkout


I have thought long and hard about whether to just post this information and give it away for free as it costs me a fair bit of both time and money to get this working, however the value to myself and my clients of getting this working coupled with the amount of help i have received in similar circumstances in the past made the final decision a no brainer, …so here it is.

However for the first time i will say, please consider how long you have spent trying to find an answer to solving this problem and the value of that time and if you have the means, say thanks:

<form action="" method="post"><input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="8C937HHT78DWG" />
<input type="image" name="submit" src="" alt="PayPal - The safer, easier way to pay online." />
<img src="" alt="" width="1" height="1" border="0" /></form>

Ok, now onto the good stuff.

The problem first, just so we are on the same page.

Shopp, the fantastic commerce plugin for WordPress has one (ok a few, but one we are dealing with here) drawbacks, namely, if you client is using Google Adwords (or even if they aren’t and merely want to track conversions) there is no way to accurately track successful transactions as there is no guaranteed return page and the receipt page of a transaction can be viewed any time by the customer at a later stage, thus rendering its usage in this process defunct.

Just quickly in case anyone is wondering what conversion tracking is, is the process of identifying whether a visit to your site resulted in a successful transaction , which obviously is essential for monitoring the effectiveness of the shop and any marketing, changes, SEO, etc…

When coupled with AdWords conversion tracking becomes even more important as you can track which keywords resulted in sales and therefore where to use your AdWords budget for most effective conversions and where money might be being wasted on high value keywords that rarely lead to sales.

Now, onto the good stuff, ….this article assumes the following:

  • you have a working version of Shopp (1.1.4 at time of writing)
  • you have the latest version of WordPress (3.0.1 at time of writing)
  • you have or have access to a Google Analytics account associated with the website in question
  • you are comfortable editing WordPress theme files
  • you are using a Shopp theme in your TEMPLATE folder as opposed to the theme inside the plugin folder (otherwise everything gets lost when you update Shopp!)

Step 1: Enable e-commerce from within Google Analytics.

Steps to do this are laid out below, ..but before you do this there are a couple of points to raise. You MUST be using the newest google tracking code, ..if you have not updated from the old code please do so. Also, if like me you were using an Analytics plugin, you may need to stop doing this and add your Analytics code manually (this is not 100% true, but you must make sure you code is being outputted in the footer and for sanities sake i suggest you make it work without a plugin, check it is working, then move back to the plugin and confirm it still works).

  1. Log in to your Google Analytics account.
  2. Click the Edit link next to the profile you want to enable. This link appears in the Settings column.
  3. On the Profile Settings page, click the Edit link in the Main Website Profile Information box.
  4. Change the selected E-Commerce Website radio button from No to Yes.

Step 2: Enter the tracking code in your theme footer for the checkout.php

The best way to add this JS file is to do so on the footer (i do not think exact location matters too much, but common sense says BELOW wp_footer() and above your normal tracking analytics code).

Also, you can add this for every page, but it is only required on the checkout.php page, so i prefer never to load anything unnecessary into a page if not require.

The location of the theme footer will be…


…and the line you need to add is…

<script type="text/javascript" src=""></script>

..however to restrict to just the checkout page you would use one of the following ‘if’ statements (depending on whether you prefer to use the ID or NAME of the page – i always go for ID, it allows you to change the name with no knock-on effect).

<?php if(is_page('checkout')): ?>
<script type="text/javascript" src=""></script>
<?php endif; ?>

…or …

<?php if(is_page(ID_OF_PAGE)): ?>
<script type="text/javascript" src=""></script>
<?php endif; ?> 

Modify the checkout.php form

If you open the checkout.php page in side the Shopp theme (inside YOUR theme, NOT the Shopp plugin folder) you need to add an onSubmit attribute to the <form> tag, and a hidden field just below.
The onSubmit attribute is…

onsubmit="_gaq.push(function() {var pageTracker = _gaq._getAsyncTracker(); setUrchinInputCode(pageTracker);});"

*this will NOT work if you are using OLD analytics code!!

…and then the hidden form field that you create just below is:

<input type="hidden" name="analyticsdata" value="" /> your completed form tag and extra field will look like this…

<form id="checkout" class="shopp" action="<?php shopp('checkout','url'); ?>" method="post" onsubmit="_gaq.push(function() {var pageTracker = _gaq._getAsyncTracker(); setUrchinInputCode(pageTracker);});">
<input type="hidden" name="analyticsdata" value="" />

…and that’s it, …conversion tracking is now working :)

It will take a few hours for data to start being recorded, but if you check the ‘e-commerce’ tab of Analytics you will see conversions coming through and when viewing ‘sources’ if you click ‘google cpc’ (assuming you have an adwords campaign) you can now view the conversions generated by specific keywords.

I hope this helps you out and saves you time.

Leave a comment...


  1. Interesting approach. I never considered the danger of using receipt.php.

    It seems like there is a potential weakness here. Since you’re attaching to the onSubmit action of the checkout form, there is no way to guarantee they actually complete the checkout process as paid orders require an additional confirmation. (Free order process directly from checkout.php)

    Have you seen this?

  2. mog says:

    This is a good point, …but as my client had been waiting for 6 months to get any kind of information as to the conversion success of the small fortune they were spending on adwords, …this was a welcome relief. The issue I had was the the process fo Shopp was changing quite a bit at the time with a different flow being used for different payment systems, so I needed something that worked for all.
    The difficultly with doing it upon transaction completion was that the cart object is emptied when submitting to Google, and any return functions would have mena’t messing with the Shopp core, which I definitely wanted to avoid for obvious reasons.

    Now there is an extra interesting point to make, …I watch the conversion amounts and numbers very carefully for the stores I manage and it seems to actually be accurate to completed transactions, rather than as you suggest, simply going to checkout, …I know this form test days when I have had many people submit carts but not complete payment, …so perhaps there is something going on here behind the scenes beyond my technical knowledge that allows Google to know a competed transaction, ….of course I am only using GoogleCheckout for all of my payments, so I do not speak for other methods.

    If you find another solution by all means let me know, I would be most interested. Thanks for your comment.

  3. Steven says:

    If you’re just tracking goal conversions with Google Analytics, shouldn’t you be able to simply add


    into the goal setup interface? That page is what comes up after completing an order successfully….at least on my site.

    I’m guessing this tutorial was meant specifically for AdWords conversion tracking?

  4. mog says:

    not if you are using GC or Paypal, ..they do not guarantee a return ;)

  5. Ninusik says:

    You say that your conversion tracking code has to be put in the footer and “above the normal GA tracking code”. But the new GA tracking code has to be put in the header (as Google says, above the tag) So, does your code go in the footer and normal GA code goes in the header?

  6. mog says:

    The reason they ask you these days to place the ga code in the header is to ensure it is parsed even if the users leaves the page quickly after arrival, …but it does still work in the footer, ..however yes, the code will work also in the header, just make sure the js include is in a conditional so you do not need to lead it in for every page of your site, ..and just BEFORE the ga code.

This site is not up to date. I really should take it down and make a new one as I have been busy with a lot of cool projects and clients recently, but currently do not have the time to rebuild it.

So, it stays here, but please note it has not been updated in a while and if you need to get in contact with me please just email me directly at or phone me on +44 (0)7960 214407.


Marcus (mog)