How do track my sales using Google Analytics?

Article Details
URL: https://www.claimtheweb.com/support/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=20
Article ID: 20
Created On: 06 Oct 2008 03:00 PM

Answer Google provides you with a code snippet to be placed on the Thank-You page (completed.html) 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.

MAKE SURE YOU REPLACE YOUR TRACKER ID WITH THE CODE PROVIDE FEOM YOUR GOOGLE ACCOUNT.

<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>