boldsupport
6/19/2017 - 11:13 PM

[RO] Google Analytics - Ecommerce Tracking Script

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

Google Analytics - Ecommerce Tracking Script

Recurring Orders Integrations

This script will track all of the following information in your Ecommerce Reports (must be enabled in GA):

  • Myshopify Domain
  • Order Number
  • Order Total
  • Shipping Total
  • Tax Total
  • Product Title
  • Product Quantity
  • Product Price

and will also:

  • Create a GA "Successful Checkout" Event