Tracking All Traffic & Transaction of Ecommerce Using Google Analytics

Tracking traffic and transaction relating to E-commerce website can provide you the very useful information relating to users and purchase made on your website. There are various way to track the users and traction. In this article we are going to discuss in detail the Google Analytics “E-commerce Tracking”.

How Actually Transaction Tracking Done?

When user click on “Purchase/Add To Cart” button the user information is recorded over sever and redirected to the “Thank You/Receipt” page. Using Google Analytics script the data (ecommerce transaction) is recorded in the Google Analytics under E-commerce section.

There are two types of data send using Google Analytics Script to the Google Analytics –

  • 1. Transaction Data
  • 2. Item Data

Transaction Data – Transaction data represent the complete information relating to the transaction happen on your e-commerce website.

Item Data – Item data represent the information relating to the individual item added in the cart.


Procedure To Implement Ecommerce Tracking In Google Analytics

By following the 5 simple steps you can implement the Ecommerce Tracking in Google Analytics.

  • 1. Load Ecommerce Plugin
  • 2. Adding Transaction
  • 3. Adding Items
  • 4. Sending Data
  • 5. Clearing Data

Below is code which helps you to track every single transaction and item purchased over your ecommerce website. For the PHP based website you can use the below mentioned code.

In the below mentioned code you can see the we have integrated the java script relating to Loading of ecommerce, adding transaction, adding items, sending data and clearing data.



<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’, ‘UA-XXXXXX-XX’, ‘auto’);

ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);

<?php
If($_SERVER[SCRIPT_NAME]==/thankyou.php”) {
?>
ga(‘ecommerce:addTransaction’, {
‘id’: ‘<? = $orders[‘order_id’]?>’,
‘affiliation’: ‘<? = $orders[‘store_name’]?>’,
‘revenue’: ‘<? = $orders[‘revenue’]?>’,
‘shipping’: ‘<? = $orders[‘shipping’]?>’,
‘tax’: ‘<? = $orders[‘tax’]?>’
});
<?php

for ($i=0;$n=sizeof($products_array);$i<$n;$i++) { ?> ga(‘ecommerce:addItem’, { ‘id’: ‘<? = $orders[‘order_id’] ?>’, ‘name’: ‘<? =$products_array[$i][‘name’] ?>’, ‘sku’: ‘<? =$products_array[$i][‘sku’] ?>’,
‘category’: ‘<? =$products_array[$i][‘category’] ?>’,
‘price’: ‘<? =$products_array[$i][‘price’] ?>’,
‘quantity’: ‘<? =$products_array[$i][‘quantity’] ?>’
});
}
?>

ga(‘ecommerce:send’);

ga(‘send’, ‘pageview’);

</script>

The above code is just the sample. You can get the idea from this only. You need to create your own based on the website and technology.


Steps To Perform In Google Analytics To Track Ecommerce Tracking

Few simple steps can help you to track every single transaction and product purchase.

1. Go to the Google Analytics

https://www.google.com/analytics/


2. Integrate the Google Analytics Code in all the page of your website by integrating this code in the header part of the blog. To get the deep insight explore our blog on “Google Analytics Code Placement“.


3. Integrate the Shopping cart with Google Analytics.


4. Integrate the Ecommerce tracking code in the order confirmation page i.e. Thank you/Receipt page. This helps you to track every single transaction on your website. The code is specified above.


5. To get the Ecommerce report you need to enable the Ecommerce reporting in Google Analytics.

The path –

Admin -> View -> Ecommerce Setting -> Enable Ecommerce Toggle button

Once done click on “Submit” button


ecommerce-tracking

6. Want to track the path of the visitor which he/she took before moving to checkout page. To do so, you can create a funnel.

Follow us on social platform to get updated with Google Updates and Digital Marketing Concept.