Get ready to use Google Analytics 4 in Magento 2

In about a year, the Google Analytics you are currently using will stop working. Google is preparing to end the transition to the next generation of analytics in July 2023. Stores that want to keep tracking their shoppers will have to use Google Analytics 4 instead of the current Google Universal Analytics.

Google Analytics 4 is a major update that reflects the evolution of the modern internet and apps. It moves away from sessions to events, allowing for tracking the full customer journey across multiple online places, such as websites and apps.

Transitioning to new analytics may be hard since some regular reports have been removed or replaced. Marketers will have to accept the unavailability of such familiar metrics as average and bounce.

We’ve prepared a brief highlight of the major differences between current Google Universal Analytics and Google Analytics 4. Additionally, you’ll know how to connect your Magento 2 to the new analytics.

  1. What is Google Analytics 4
  2. New tracking capabilities of Google Analytics 4
  3. Google Analytics in Magento 2
  4. Summary

What is Google Analytics 4

Google Analytics 4 (GA 4) is a global update of the analytics service provided by Google. It has been publicly tested since 2020, and it significantly differs from the currently used Google Universal Analytics (GA 3).

As for now, online stores may utilize any analytics solution they find best; however, starting July 2023, Universal Analytics will be disconnected.

The major difference between Universal Analytics and GA 4 is the transition from the sessions to events, allowing the collection of standardized data across all platforms. In such a way, it becomes possible to get a single report along the entire user journey.

GA 4 also provides machine learning and NLP (Natural Language Processing). This allows to predict the conversion probability and use such data for Google Ads campaigns. Machine learning can also help find anomalies in reports, like no conversion tracking or wrong conversion coefficient calculation.

How Google Analytics 4 differs from current Google Universal Analytics

Google Analytics 4 has several other key differences when compared to Universal Analytics:

  • New data model. This can be named the most global difference between old and new Google analytics. The new data model moves from sessions and page views to events and parameters. In Google Analytics 4, every user action is classified as an event. The latter can be collected by default or configured manually. Each event can contain up to 25 custom parameters. For example, a page view is considered an event, and the page language, screen resolution, and page referrer - are event parameters.

  • Data streams. Google Analytics 4 collects data from the websites and apps in the form of data streams, which are a part of a single Analytics property. Universal Analytics uses separate Analytics properties for each data source, for example, a website or mobile app. In GA 4, it is easier to analyze and track traffic across different sources.

  • Timely restrictions on data viewing. Universal Analytics has no time restrictions to view historical statistics. GA 4 offers data for the last 14 months. For longer periods, a Google BigQuery is required.

  • IP address anonymity. New Analytics provides more anonymity since IP anonymization is enabled by default.

  • Two cookie files. GA 4 tracks user activity with not one, but two cookie files. Both files have a lifespan of two years.

  • Segmented Analysis with more power. New Analytics offers an increased number of parameters, metrics, and relationships between them and events. This makes audience analysis more powerful. For example, predicting the number of buyers in the following week.

  • Cross-domain tracking. Track conversions by their real sources and exclude middleman websites. For example, when a user authorizes with a social network, the conversion may be linked to the social network, although email is the real source. Cross-domain tracking allows tracking the real source of conversion.

  • Engagement Tracking is made with new metrics. Google Analytics 4 tracks engagement by Sessions with interaction, Engagement rate, and Time of involvement. The latter could not be tracked on smartphones with Universal Analytics.

  • Standard Reports are presented with fewer reports: Users, Demographics, Behaviors, and Devices.

  • The Custom Reports option brings customizable reports that were available only in paid GA 360. Additionally, new Analytics integrates with Google BigQuery.

  • Custom insights and Anomaly Detection. Set up monitoring of most critical events. For example, configure tracking of anomalies of the data gathering in analytics. In GA 4, monitoring can be done hourly; in GA 3, the frequency is one day.

  • Path Analysis. Google Analytics 4 provides the customer path analysis, which was only available in paid GA 360.

  • Integration with BigQuery. Google Analytics 4 introduces free integration with BigQuery. Integration is limited to 50 text and 50 numeric parameters for events.

New tracking capabilities of Google Analytics 4

GA4 is a complete overhaul of the user tracking process that combines user behavior monitoring on the web and app. This tool offers some new tracking capabilities for businesses.

Event tracking from the start

Basic events, such as clicking on an ad or link, a purchase in the mobile application, canceling of paid subscription, scroll tracking, site searches, video engagement, and dozens of other important events with GA 4 are available right after the Enhanced Measurement option activation. No need to write any code, unlike with the previous Universal Analytics.

Custom event tracking

In addition to events and parameters tracked by default, the GA4 completely opens up tracking allowing monitoring of custom parameters. Marketers can customize tracking of predefined events from such groups as Automated Events and Recommended Events. In case of additional tracking requirements, there is an option to configure Custom Events for anything not covered by predefined configuration.

Tracking on any platform

New GA 4 is more convenient in tracking customers across multiple platforms, which is a major problem for Universal Analytics. It provides a comprehensive history of user activity for every tracked app or website. Marketers will get a more accurate user count since GA4 is much better at de-duplicating users across devices.

Engagement measuring

The bounce rate metric used to depict unengaged users becomes a matter of the past in GA4. With the new Analytics, marketers can see how deeply engaged customer was during their journey. For example, it becomes possible to track what video the user launched, watching pauses they made, and whether they fully viewed it.

AI for predicting outcomes

This functionality may not directly relate to track, but it is a major part of GA4 that helps optimize marketing campaigns alongside user activity tracking. Using artificial intellect, the Analytics will analyze the historical user tracking data and predict future user behavior.

AI will help marketers make informed assumptions on such events as purchases, user churn rate, revenue, etc. In such a way, a business can know what marketing activity to focus on to get the best results.

Google Analytics in Magento 2

Magento provides embedded support for Google Analytics; however, as for Magento 2.4.4, this e-commerce platform does not have the data layer required for the new Analytics.

Therefore, only the previous Universal Analytics can be configured out of the box. The GA 4 requires a third-party plugin. Use the Chrome Tag Assistant Legacy extension to check the GA tags are implemented correctly.

How to add Universal Analytics in Magento

Configuring the Universal Analytics in Magento is rather straightforward.

  1. Ensure the module Magento_GoogleAnalytics is installed and active. This module is a part of the Magento bundle. Use command bin/magento module:status to check the module status. See how to enable an extension in the Magento store.

  2. Create a Google Universal Analytics account. Write down your account tracking number, which starts from UA-.

  3. In the store Admin navigate to Stores > Settings > Configuration > Sales > Google API > Google Analytics. Enable it, provide your account number, and save the configuration.

How to add Google Analytics 4 in Magento

To embed the GA 4 in your Magento store, follow this algorithm:

  1. In your Google Analytics account, create a new Google Analytics 4 property. Use the GA4 Setup Assistant that Google provides.

  2. Create a data stream (your store) for this property and enable Enhanced Measurement to capture events. Write down your measurement ID, which starts from G- (image credit: Google):

  1. Create a new Google Tag Manager account. You will get two codes that you need to add to your store with a third-party module. For example, you may use a Google Tag Manager.

  2. In your GA 4 data stream, create a new tag to gather user activity data. See the detailed guide on creating a GA4 tag.

  3. Create custom events you wish to track.


The eCommerce business is one of the main beneficiaries of the new Google Analytics 4. This tool is designed to track the customer journey across domains and devices.

With GA 4, stores on Magento 2 can track events not only on the website but also in the mobile app and other sales channels. They get a much deeper ability to analyze the user actions sequence than in UA. As a result, finding bottlenecks in the sales funnels becomes much easier. Additionally, a business can build more personalized communication with customers when knowing their behavior.

Albeit Google Analytics 4 offers a completely new approach to user actions, data gathering, and analysis, it requires some effort from marketers to master it.

A good piece of advice is to start studying this analytics platform while you can still use your current Google Universal Analytics. You can then easily switch to a new Google Analytics 4 when Google shuts down Universal Analytics in 2023.

Additionally, you can extend your analytics and reporting stack by using Magento 2 Advanced Reports as extra-powerful platform for ecommerce reporting.

Eugen Barilyuk


Eugen, a tech-savvy writer at an IT company. He spends his days simplifying complicated tech stuff into easy-to-read blog posts and documentation. Eugen loves blending his love for tech with storytelling, making complex topics not only understandable but interesting. Beyond work, he enjoys exploring the creative side of technology and innovation.