Magento 2.x – How to Integrate Google Analytics

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.

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

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.