Adding products is not enough for a successful online business. You need to understand your audience. This is where Magento Google Analytics comes in handy. It is a tool that will help you track users' engagement on every page of your store.

Create Account

  • To start with the process, you will have to create an account on Google Analytics.
  • Go to the website to create yourself an account if you have not got one.
  • Here’s how to create one:
  • When logging in successfully, click Start Measuring.

Account setup

You must mention your account name. It could be any name.

Property setup

Enter a Property name, then click next.

About your business

Select correct your business then click create.

Google Analytics Terms of Service Agreement

You have to select the name of the country you are in:

Finally, click “Accept”. This will complete the creation of your Google Analytics account.

Tracking Code

  • Select the option of platforms you want to track data on. It is “Web”, generally.
  • You need to mention the name of the website & its URL. Then click Create stream.
  • To be able to collect statistics, you will need to add a Google Analytics code to Magento 2. To find the code, navigate to the left side of your Analytics dashboard. In there you will see the Admin Tab. Click on it and choose Tracking Info. There you need to open the Tracking Code.

You will be needing both i.e. Tracking ID & Tracking Code.

Add Google Analytics API to Magento 2.x

Moving forward to the next step. Now go to your website and log in to the Admin Panel. Choose Stores from the left-side menu. In block Setting, you need to find Configuration:

Expand the Google Analytics section and do the following:

  • Set Enable field to Yes
  • Enter your Google Analytics Account Number
  • If you want to conduct A/B testing and other performance tests on your content, set Content Experiments to Yes.

Navigate to Content > Configuration (Open tab HTML Head) paste the Global site tag code in the Scripts and Style Sheets section.

Finally, you need just to check if everything is set up fine. Just open your website frontend and Magento Google Analytics account in the second tab. Choose a Real-Time report. There should be 1 active user on site right now:

Use Google Tag Assistant Chrome extension

  • Add Tag Assistant Legacy extension to Chrome
  • To enable Tag Assistant, click the icon on the top right-hand side.
  • Then click on the ‘Enable’ button and then refresh the web page:
  • Result Google Tag Assistant:


So we have finished our detailed guide on how to set up Google Analytics for your Magento 2 website. If you have any questions regarding our guide, please write them down in the comment section or send them to us via our contact line.