Knowledgebase: Marketing Tools
How do I use Google Analytics to track sales?
Posted by Michael G.K on 30 August 2008 06:41 AM

Google provides you with a code snippet to be placed on the Thank-You page of your cart to track sales through Google Analytics. This code looks something similar to this:

<body onLoad="javascript:__utmSetTrans()">

<form style="display:none;" name="utmform">
<textarea id="utmtrans">UTM:T|[order-id]|[affiliation]|
[total]|[tax]| [shipping]|[city]|[state]|[country] UTM:I|[order-id]|
[sku/code]|[productname]|[category]|[price]|
[quantity] </textarea>
</form>


The shopping cart requires some slight adjustments to track sales information within it's system.

Please make the changes outlined below, or simply copy and paste the snippet below into the completed.html page found in the /content/skins area of File Manager.

<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-xxxxxxx-x");
  pageTracker._initData();
  pageTracker._trackPageview();

  pageTracker._addTrans(
    "{$order_id}",   // Order ID
    "{$affiliation}",   // Affiliation
    "{$order_amount}",   // Total
    "{$tax}",   // Tax
    "{$shipping_amount}",   // Shipping
    "{$city}",   // City
    "{$region}",   // State
    "{$country}"   // Country
  );


{foreach from=$items item="item"}

  pageTracker._addItem(
    "{$order_id}",   // Order ID
    "{$item.sku}",   // SKU
    "{$item.product_name}",   // Product Name
    "{$item.catalog_name}",   // Category
    "{$item.price}",   // Price
    "{$item.quantity}"   // Quantity
  );

{/foreach}

  pageTracker._trackTrans();
</script>

(348 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).