[RO] Google Analytics - Ecommerce Tracking Script
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '[tracking_id]', 'auto');
ga('require', 'ecommerce');
//create a GA ecommerce transaction
ga('ecommerce:addTransaction', {
'id': '[order_name]',
'affiliation': '[myshopify_domain]',
'revenue':'[total]',
'shipping':'[shipping]',
'tax':'[tax]'
});
//add items to the ecommerce cart
for(var i = 0; i < products_json.length; i++){
var item = products_json[i];
ga('ecommerce:addItem', {
'id':'[order_name]',
'name':item.title,
'category':'Recurring Orders Checkout',
'price':item.price,
'quantity':item.quantity,
'sku':item.title
});
}
ga('ecommerce:send');
ga('send', 'event', 'Checkout', 'Successful Checkout');
</script>This script will track all of the following information in your Ecommerce Reports (must be enabled in GA):
and will also: