ECommerce Tracking With Google Analytics
January 7, 2009Installing eCommerce tracking with Google Analytics is usually a pretty easy job with the wealth of osCommerce contributions that have been made by the osCommerce community. However, if the installation of osCommerce has been heavily modified, it can make the installation pretty difficult. When checking and troubleshooting an osCommerce tracking installation with google analytics I would normally check the following:
Do a ‘view source’ on your checkout_success.php page. When an order is run though, it should contain the normal Google Analytics code (it’s easiest to use the new version of the Analytcs tracking code):
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXXXXX-1");
pageTracker._trackPageview();
} catch(err) {}</script>
Underneath this, you should be including the tracking code. This code basically sends Google the order id, product id, price, delivery, city, state and a host of other information. There are a few different variations of this code, but the version that Google recommends on its help pages looks like this:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-XXXXX-1");
pageTracker._trackPageview();
//The following fields need OSCommerce variables for the relevant values inserted. They will look something like “$order->info['order_id']”
pageTracker._addTrans(
"", // Order ID
"", // Affiliation
"", // Total
"", // Tax
"", // Shipping
"", // City
"", // State
"" // Country
);
pageTracker._addItem(
"", // Order ID
"", // SKU
"", // Product Name
"", // Category
"", // Price
"" // Quantity
);
pageTracker._trackTrans();
</script>
The most important thing to check is the order that the values appear in the addTrans and _addItem functions. This should pretty much get it all working for you. Don’t forget to fill the tracking code into the sections marked with XXXXXXX as with a normal google analytics installation.
Simon Davies
SEO Programmer
No Comments
No comments yet.
RSS feed for comments on this post
TrackBack URI
Leave a comment
Just Search Weblog
Archives:
Pages:
Meta:
Categories:
- Accessibility
- Affiliate Marketing
- Content Writing
- Cowboys
- Downloads
- Internet Marketing
- Job Vacancies
- Latest News
- Pay Per Click
- Press Releases
- Search Engine Optimisation
- Testimonials
- Web Analytics
- XHTML














