Post Contents:Â
- What is Google Analytics 4?
- Benefits of Google Analytics 4.
- How to Set up Google Analytics 4 in Magento 2.
- Create GA4 Property
- Get your Measurement ID
- Set up a Google Tag Manager Account and Container
- Get your Public ID, Account ID, and Container ID
- Install Magento 2 Google Analytics 4 Extension
- Paste your GTM and GA4 IDs into the Magento Admin
- Generate GTM Tags
- Test the GTM Connection
- Check Google Analytics 4 in real-time.
What is Google Analytics 4?
After being put through public testing since 2020, Google Analytics 4 (GA4) is a next-generation measuring system based upon the foundation of Universal Analytics (GA3). It has extensive interactions with Google advertising platforms and uses machine intelligence. It provides you with information about how clients use various platforms and gadgets. Furthermore, the GA4 measurement mechanism is based on events and parameters, whereas Universal Analytics (GA3) monitors data based on page views and sessions. GA4 takes eCommerce tracking to a new dimension. And now, due to better integration with Google Ads, you can segment your website visitors using these events and retarget them.Benefits of Google Analytics 4
Since we now know that it represents a significant advancement in data tracking, let us focus on GA4’s best features.1. Data Streams
Google Analytics 4’s ability to track data on your website, mobile app, or both in a single property is one of its greatest features. One property can contain several data streams, such as iOS, Web, and Android.Â
2. Customer Journey Tracking
With the GA4 edition, Google Analytics has undergone fundamental changes. Instead of focusing on sessions, the focus is now on users and their interactions with your store, as documented by events. Even if a consumer views your business from a mobile device, returns later on a desktop, and completes a purchase using an app, you can still create a customer journey for them.3. Focus on User Management
GA4 enables you to concentrate on user-centric reports because it has the capacity to gather more data and feature report menu parts that are in line with the customer journey. The lifecycle and user part now includes a study of Acquisition, Engagement, Monetization, and Retention along with demographic and technological information. Right after you create a GA property, you'll be redirected to the Web stream details where you can find the Measurement ID you'll need later. However, if you already have your property set up, go to your Google Analytics account > Admin > Data Streams and click on the data stream you need to collect the Measurement ID from.Â
4. More Segmented Audiences
More audience segments are possible with more potent analytics and reporting, which you can utilize to develop marketing campaigns that are more successful. With dynamic remarketing, you can target people based on a variety of criteria, such as those who add items to their wishlists, make purchases, and abandon their carts. Not to mention its capacity to compile information from many browsers and devices.
How to Set Up Google Analytics 4 in Magento 2?
Typically, a Google Analytics tracking code must be inserted into the <head> section of your website to add Google Analytics to Magento 2. It is not only inefficient but also inconvenient for anyone without technological expertise. Using Google Tag Manager (GTM) is the most effective method for adding Google Analytics 4 to Magento. With GTM, you can track client journeys by adding various e-commerce events with flexibility. You will not even have to perform the task by hand.1. Create GA4 Property
You must first establish a GA4 property before you can begin adding GA4 to Magento. Proceed to the next step if you already have one. Go to Google Analytics and select Get Started Now to begin setting up a GA4 property. You must choose the Account Data Sharing Settings and provide your account name.



2. Get your Measurement ID
Right after you create a GA property, you'll be redirected to the Web stream details where you can find the Measurement ID you'll need later. However, if you already have your property set up, go to your Google Analytics account > Admin > Data Streams and click on the data stream you need to collect the measurement ID from.3. Set Up a Google Tag Manager Account and Container
Since we added Google Analytics 4 to Magento through Google Tag Manager, you need to set it up too. As with the GA account, if you've already set up the GTM account, move on to the next step. Go to the GTM homepage and press the Create Account button. Then, set the account Name, Country, and Container name, and choose the target platform.Â
4. Get your Public ID, Account ID and Container ID
Apart from Google Analytics Measurement ID, you also need to get some tracking IDs from GTM. Go to the GTM homepage and choose the container you want to use for tracking.Â- Public IDÂ

- Account ID
- Container ID
5. Install Magento 2 Google Analytics 4 Extension
As we've mentioned before, Google Analytics 4 integration with Magento is much easier and less technical if you use the right solution. So the next step is to install the Magento 2 Google Analytics 4 extension and manage it from the admin panel.6. Paste your GTM and GA4 IDs into the Magento Admin

7. Generate GTM Tags
You can create different custom events like add_to_cart or initiate checkout in your GTM account manually if you like. However, if you have a Google Analytics 4 extension, you don't need to. When you're still on the extension configuration page, scroll down to the Export Web Container section and press on the Generate JSON Container & Download File button to get the file with all the essential tags.
8. Test the GTM Connections
GTM allows you to check if Google Tag Manager is working correctly right from the workspace. While you're on the container page workspace, click Preview and enter your Website URL in a popup.

9. Check Google Analytics 4 in Realtime
If the GTM tags work properly then they are collecting some data about your website visitors. So, you can go to GA4 > Reports > Realtime and monitor the activity on your store. You have added Google Analytics 4 to Magento 2! Additionally, you can debug GA4 to make sure the data is received properly by your property.