Google Analytics 4 using native logic in Adobe Commerce.

Magento Software
campaign-creators-pypeCEaJeZY-unsplash

The latest versions of Adobe Commerce have native logic to connect to Google Analytics 4 using Google Tag Manager. This approach is very convenient since it allows to work with Analytics using native features of the platform, avoiding unnecessary extensions and getting updates as soon as they are released by the Adobe team.

The setup process is pretty straightforward and is described in the documentation. All you need is to have Google Analytics and Google Tag Manager accounts.

First of all, you need to sign in to the Google Analytics account. Then enable Internal Site Search tracking, enable display features (demographics and interest reports) and enable eCommerce settings.

Then in the Google Tag Manager account, you’ll have to configure a new container with the basic settings. There is a sample configuration file offered on docs.magento.com that can simplify the process. It should be renamed to GTM_M2_Config.json and archived to GTM_M2_Config.zip and then uploaded to Google Tag Manager. After that, add your own Google Analytics ID, add tags, triggers, and variables, and publish the container.

The third stage is to configure the store in Stores > Settings > Configuration. Go to the Sales section and find Google API. Enable Google Analytics, select Google Tag Manager, enter your ID, and save config.

The last step is to add the Google Tag Manager code to the store. You need to go to Admin > Install Google Tag Manager to get the code. Then, in your store's admin panel, go to Content > Design > Configuration, open the store view in edit mode, and add the codes retrieved from GTM. The first one - is to the head section and the second one - is to the footer.

Also, you may want to configure a Monetization overview to get reports that summarize data regarding your sales. This can be configured within Google Analytics. All you need to do is to add specific eCommerce events. They allow you to track different interactions to enable you to see everything related to the sales. In total, Google Analytics will allow us to see the data regarding promotion interactions, item interactions, cart interactions, checkout processes, and refunds.