Skip to content

Instantly share code, notes, and snippets.

@gyan111
Created January 9, 2014 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyan111/8329739 to your computer and use it in GitHub Desktop.
Save gyan111/8329739 to your computer and use it in GitHub Desktop.
Reversing a google analytics ecommerce transaction, This code snippet should be added to the header.tpl in the ganalytics module.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'1234', // order ID - required
'Womens Apparel', // affiliation or store name
'-28.28', // total - required
'-1.29', // tax
'-15.00', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
]);
_gaq.push(['_addItem',
'1234', // order ID - necessary to associate item with transaction
'DD44', // SKU/code - required
'T-Shirt', // product name
'Olive Medium', // category or variation
'11.99', // unit price - required
'-1' // item quantity - required
]);
_gaq.push(['_trackTrans']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment