Featured templates

Magento 2.x. How to Integrate Google Analytics

Harry Baker August 31, 2016
Rating: 5.0. From 3 votes.
Please wait...

This guide will show you how to integrate the Google Analytics code to your Magento 2 store.

In order to add the Google Analytics code, you should perform the following:

  1. The first step is locating your account ID in Google. You will first need to obtain your tracking code from the Google Analytics account by following this detailed tutorial.

  2. You should get the code similar to the one, presented below:

    <script type="text/javascript">   
    	var _gaq = _gaq || [];    
    	_gaq.push(['_setAccount', 'UA-12345-6']);    
    	(function() {      
    	var ga = document.createElement('script');  ga.type = 'text/javascript'; ga.async = true;      
    	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';      
    	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);   
  3. UA-XXXXX-X‘ in your code ( where 12345-6 stands for your Account ID number) is your Google Account ID.

  4. Log into your Magento Admin Area and navigate to Stores -> Configuration section.

  5. Access the Sales -> Google API section and expand the Google Analytics option.

  6. Enable it and paste the tracking code to the Account Number field. Next, click on the Save Config button to apply the changes.


This is the end of the tutorial. Feel free to check the detailed video tutorial below:

Magento 2.x. How to Integrate Google Analytics
Best Magento Themes
This entry was posted in Magento Tutorials and tagged Google Analytics, magento2, tracking. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket