How to integrate Google Analytics to Magento?

Posted on October 14th, 2016

Magento is familiar to the Internet users who used it to purchase products via the web. In this article, we are going to see the Magento Analytics in detail. Let’s see what Magento is and how it’d be helpful to the website owners.


What is Magento?

The Magento can be defined as an open source ecommerce platform. It is one of the best ecommerce platforms available at the moment. It plays a vital role in the online trade. Magento provides a shopping cart system. It also allows control over the look and content and functionality over their online store. The primary specialty of the Magento is it is open source. Magento provides you with powerful marketing, search engine optimization, and catalog-management tools. Magento versions are available in various ranges from community open source to large scale enterprise SaaS based systems.

So what is ecommerce? Ecommerce is the term used for commercial transactions that is conducted on the Internet by electronic means. It often includes financial transactions such as online payment, refunds, and credits. It is also defined as the buying and selling of goods and services or transmitting funds over the Internet.


What is Google Analytics?

The Google Analytics is a free service provided by Google to monitor traffic to your website. Suppose you are the webmaster or website administrator of a website. You can track traffic and conversion ratio of your website with the help of Google Analytics. In Magento, there are two types of tracking.

1) Page View Tracking

2) Ecommerce Tracking


Page View Tracking

The page tracking is the method of measuring the number of views for a particular webpage of a website. Usually, we use the term pages to specify an entire HTML document. In the page view tracking, we can also track the views for a dynamically loaded content. This is called virtual page view.

Let us look into how to implement page tracking with analytics.js

We use JavaScript tracking snippet to implement the page tracking with the analytics.js. The JavaScript tracking snippet is the set of codes described below.

<!– Google Analytics –>



(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),



ga(‘create’, ‘UA-XXXXX-Y’, ‘auto’);

ga(‘send’, ‘pageview’);


<!– End Google Analytics –>

You need to add the above code to your website’s templates in order to start using the analytics.js. This code needs to be added before the closing head tag (</head>) and you need to replace the string “UA-XXXXX-Y” with the property ID of the Google Analytics property you wish to track. The property ID is also called tracking ID.

The above JavaScript tracking snippet includes commands to create a tracking object and to send a page view to Google Analytics. When the tracker gets created, several of its fields is set based on the browsing context. The title field is set to the value of document.title and the location field is set to the value of document.location, but ignore the anchor portion of the URL. Keep in mind that if the anchor portion of the URL contains campaign parameters, those parameters are get dept in the anchor and sent to Google Analytics for processing unless the allowAnchor field is set to false.

When the send command is executed, the title and location fields stored on the tracker get sent and Google Analytics uses those values to show which page your users visited.


Ecommerce Tracking

The Ecommerce Tracking allows you to track the number of transactions and revenue that your website generates. When a user clicks on the purchase button, the user’s purchase information is sent to the web-server that carries out the transaction. If it is a success, the web-server replies with a thank you or a receipt page. In short, ecommerce tracking will let you know the types of customers that make purchases and what they’ve purchased.

To view ecommerce data in analytics, you need to perform the following two simple steps.

1) Enable Ecommerce in your reports

2) Add code to your site or to collect ecommerce data

Let’s see each steps in detail.


Enable ecommerce in your reports

This is the primary setup you need to perform in order to implement ecommerce tracking. To enable ecommerce in your reports, you need to perform the following steps.

1) Sign into your Analytics account

2) Navigate to the desired account, property and view

3) In the VIEW column, select Ecommerce Settings.

4) Click the Enable Ecommerce toggle ON.

5) Optional: Click the Enable Related Products toggle ON.

6) Click Next step

7) Click Submit

These are the steps you need to enable ecommerce in your reports.


Add code to your website or to collect ecommerce data

Now, the next step is adding code to the website or application in question to collect ecommerce data. This can be done with the help of a web developer unless you can do it yourself.

These are the steps to enable ecommerce tracking in your website.


If you need any further assistance please contact our support department.



Leave a Reply