How to Connect Google Analytics 4 (GA4) to Magento 2? Best Practice

Connect Google Analytics 4 (GA4) to Magento 2
The digital world was lately astonished by Google’s announcement that they would be retiring the cherished and widely used Google Analytics Universal version. Standard Universal Analytics characteristics will no longer be working as of July 1, 2023.

Stores that want to continue tracking their customers must use Google Analytics 4 rather than the current Google Universal Analytics.

Why is Universal Analytics being phased out? It has been a fantastic and must-have platform with numerous benefits for any store. The turnaround is quite easy: it’s being updated! Universal Analytics is being phased out to make way for Google Analytics 4. (GA4).

We’ve prepared a brief highlight of everything you need to about this updated version along with how to transition from the universal version to G4. 

What Is Google Analytics 4 (GA4)?

Google Analytics 4 is the fourth generation of Google Analytics, which is used by vendors, organizations, and store owners to get detailed performance measures and reports on how their many products and services are being used by customers.

Google Analytics 4 is a newer version of the privacy-focused platform that Google describes as their next-generation quantification solution. With a privacy-oriented and future-friendly structure, it constructs on and enhances previous Universal Analytics characteristics.

Google Analytics 4 can keep an eye on and evaluate key trends in your site data by utilizing Google’s sophisticated machine learning algorithms, allowing you to make result-driven judgments to support your company.

Furthermore, the improved abilities of machine learning allow Google Analytics 4 to fill in significant data gaps, making it more reliable.

Is Google Analytics 4 Right for My Business?

Google Analytics 4 is an upgraded version of Google analytics universal. And if you are using an old version, it is right to opt for an updated version that has newer features. 

Even if you are new to google analytics, using an updated version is quite crucial. As with it, you’ll be getting a lot of relevant data that guides you in scaling your business. 

Let’s find some of the reasons why you should opt for Google Analytics 4? 

  • New data prototype – This is the primary distinction between old and new Google analytics. The new data model shifts away from sessions and page hits and towards occurrences and variables. We categorize every customer activity in Google Analytics 4 as an event, and each event can have up to 25 tailored parameters.
  • Tracking across multiple domains – You can effectively monitor conversions by their true source materials by excluding middleman websites with the newer version of Google Analytics. Cross-domain tracking enables tracking of the true source of conversion, resulting in more customized outcomes.
  • Easy Big Query integration – Google Analytics 4 now includes free Big Query integration.
  • Custom understandings and anomaly detection – G4 allows you to easily set up supervision of the most important incidents. We can do the hourly measurement in GA 4, but only once a day in GA 3.
  • Path Analysis – Google Analytics 4 includes customer path analysis, which was exclusively available in the paid GA 360.
  • Data streams – In Google Analytics 4, data streams gather information from websites and apps and are part of a specific Analytics property. Universal Analytics employs distinct Analytics characteristics for each source of data, making it much easier to monitor traffic from multiple sources.
  • Structured segmentation – New Analytics includes more parameters, metrics, and connections between them and events. This increases the potency of audience analysis.
  • Engagement monitoring is made possible by new performance measures – Google Analytics 4 tracks interaction by Sessions with the conversation, Engagement metrics, and Time of participation, which Universal Analytics does not.

How to Connect Google Analytics 4 to Magento 2 Store

Google Tag Manager is the platform to connect Google Analytics to Magento. As a result, Google Tag Manager provides you with more management alternatives when dealing with Google Analytics and other promotional tools such as Google Ads or Facebook.

Without any further delay, let’s learn how you can connect Google Analytics 4 to Magento 2 through Google Tag Manager. Let’s get started! 

Step 1: Generate a “Google Tag Manager” account. 

The first stage in the integration process is to create a Google Tag Manager account. In the tag manager, press the “Get started for free” tab to get started. To get started, you could even watch the short tutorial videos on how you can generate your initial GTM account. You’ll also get a summary of the interface and account configuration in the video.

Step 2: Download the Google Tag Manager extension

There is a wide variety of GTM extensions from which to choose! You can navigate extensively and select the ideal augmentation with the best features that meet your needs.

In a broad sense, they must all adhere to the Google documentation for GA4 Enhanced eCommerce configuration. So all you have to do is select the GTM and attach it to the GTM plugin. Irrespective of the extension provider, the entire procedure is quite simple.

Step 3: Connect the Google tag manager with the Magento GTM extension. 

  • Press on the GTM Identification number in your GTM container.
  • Then, only the GTM Identification number from the script should be copied.
  • Access your Magento GTM plugin and paste the GTM ID number into the Stores > Configuration > Sales > Google API > Google Tag Manager segment. After you save all the settings, the GTM will be linked to your Magento webshop.
  • You can check it by locating the Google tag manager ID number in your web shop’s preview pane. Alternatively, you can download the browser plugin of Tag Assistant Legacy. It is a beneficial plugin that can assist you in troubleshooting GTM and Google Analytics installations, as well as provide some other information.

Step 4: Adding a Google Analytics 4 configuration tag in GTM.  

  • In GTM, generate a GA4 setup tag.
  • For this phase, you must first create a GA4 property. Now, access the GTM container and, in the Tags segment, tap the “New” button.
  • And after that, to access tag types, tap on the Tag phase space.
  • After selecting the GA4 setup tag types, join your GA4 Metrics ID details. The GA4 tracking code is positioned in the very same location as the Measurement ID.
  • Now, go to the triggering part and click the “All Pages” trigger. Then, give your label the name “GA4 Setup” and save it.
  • That’s the end of it. You used Google Tag Manager to attach your Google Analytics property to your Magento eCommerce store.

Step 5: In the end, test your connection. 

In GTM Design View, check your relation.

Verify your Google Analytics GA4 property to see if you’re getting traffic. GA4 takes a while to display visitors, however, you can check your connection right away by tapping the “preview” key in your Google tag manager container. Add your website’s URL and press “Connect.”

GTM will launch your webshop in a new tab. Go over to your GA4 property and allow access to the Debug view functionality in the Configuration document.

You should be seeing a page view event that took place when the GTM enables your webshop in a new tab, indicating that Google Analytics is receiving hits and is linked to your webshop.

Proceed to navigate your website and notice which events are beginning to appear in Google Analytics’ Debug view.

Using Magento 2 enhanced ecommerce extensions to add google analytics 4 tracking through google tag manager

By analysing the instructions outlined above, you will have set up an easy Google Analytics 4 to Magento 2 store and will monitor the following:

  • Page views
  • Scrolling time
  • Outgoing clicks 
  • File installs

These are all fantastic measures to have, but Google Analytics 4 has even more specific and personalized info about the user and products that help businesses in developing personalized strategies and make judgments that will keep them ahead of the competition and Magento Store going & rising. 

These metrics are classified as Enhanced eCommerce and include characteristics such as

  • Rate of conversion
  • Effectiveness of revenue per product
  • Product-specific metrics
  • Checkout Procedures (billing, shipping, and payment process)
  • Drop-off at the checkout step
  • Product first impressions (Category Wise)
  • Clicks on products (Category wise)
  • Cart activities (additions, removals)
  • Use of a coupon code
  • Impressions and click-throughs on advertising items

Please keep in mind that these are just several Enhanced eCommerce performance measures you can use. There are numerous others that you can use for your Magento store!

How Does the Google Analytics 4 (Ga4) Extension for Magento 2 Work?

This Enhanced eCommerce extension installs in a matter of minutes and allows you to fully integrate your Google analytics 4 to Magento 2 store as well as Google AdWords.

The module is simple to set up and comes with a detailed step-by-step handbook. Simply download the plugin, follow the setup steps to build a JSON file containing all the new Tags, Triggers, and Variables, and transfer it into Google Tag Manager to overwrite or combine with the old labels. 

Then save the setups and you’re prepared to go, no code changes are required!

The extension will begin sending Enhanced eCommerce information to Google Analytics 4 via the database layer and initiate evaluating the events that matter for your Magento 2 shop, allowing you to gain the necessary insights to run your company!

New Tracking Capabilities of Google Analytics 4

GA4 is a total overhaul of the user tracking method that links web and app user behaviour tracking. This tool provides businesses with new tracking capabilities.

  • Advanced functionalities 

Basic occurrences such as tapping on an ad or link, making purchases in the smartphone app, stopping a paid subscription, scroll monitoring, site search queries, video interaction, and dozens of other essential GA 4 events. 

They are available immediately after activating the enhanced measurement alternative. Unlike the prior Universal Analytics, no code is required in this version.

  • Customized implementations 

The GA4 entirely opens up real-time monitoring, enabling surveillance of custom variables in addition to the occurrences and variables monitored by default. Marketing companies can tailor monitoring of predetermined happenings from categories such as Automated Events and Suggested Events.

In the circumstance that you need to track something that isn’t covered by the pre-defined setup, you can customize Custom Events.

  • Seamless monitoring 

The new GA 4 makes it easier to monitor consumers throughout different platforms, which is a major concern for Universal Analytics. It offers a detailed background of user behaviour for each monitored app or website. Because GA4 is much preferable at de-duplicating customers across devices, marketing companies would get a more accurate user count.

  • User engagement time 

The bounce rate measurement represented unengaged users. Marketers can now see how engaged their customers were throughout their journey using the new Analytics.

For instance, with G4, we can monitor how long a user spends watching a video, how many times they pause, and whether they completely view it or not.

  • Leveraging Artificial Intelligence 

This feature may not be directly related to tracking, but it is an important part of GA4 that aids in the optimization of advertising campaigns as well as user activity monitoring. The Analytics characteristic will evaluate chronological user tracking data and predict potential user activity using artificial intelligence.

AI will assist marketers in making informed assumptions about events such as purchases, user churn rate, earnings, and so forth. In this manner, a company can determine which marketing activities to prioritize to achieve the best results.


So, that is all you need to know about the newly introduced version of google analytics and its integration with Magento 2. Hope that you have to find this guide helpful in setting up Magento 2-GA4-Google Analytics 4 with GTM useful. The built-in occurrences that are crucial for eCommerce make the configuration simpler and more seamless.

After completing this guide, you should be able to incorporate Google Analytics into Magento 2 to track the traffic to your store. With GA 4, Magento 2 shops can monitor happenings not only on their website but also on their phone app and other online marketplaces. They gain a much deeper understanding of user actions. 

As a result, identifying inefficiencies in sales funnels becomes so much simpler, and businesses can build more customized communication with customers when they understand their behaviour.

If you have any problems related to Magento Development, feel free to reach out to us, we would love to help!

Recent Articles

Browse some of our latest articles...