This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

🔊 Web Growth Summit is here! Learn from industry experts on July 17-18, 2024. REGISTER NOW→

How to Set up and Integrate Google Analytics 4 for Magento Ecommerce Tracking

Updated on October 13, 2023

7 Min Read
Setup Google Analytics 4 On Magento

Tracking the performances of your Magento stores is a necessary feat. Neglect that, and you’ll have a store that underperforms and doesn’t give you any insights for growth or performance.

To avoid that pitfall, it’s essential that you closely track your Magento store’s activity. And the new Google Analytics 4 can help you achieve that goal.

In this article, I’ll show you how to track your store’s performance using Google Analytics 4. Of course, several other options are available, but they are either paid or ineffective.

GA4, on the other hand, is free and offers amazing store insights in real-time, such as visitors, page sessions, conversions, etc.

So, let’s get down to the crux and explore more about GA4 and its integration with your Magento stores.

Overview of Google Analytics 4

Google Analytics 4 (GA4) was recently rolled out by Google as a substitute for Universal Analytics (UA). Initially, both ran parallelly, but the company stopped UA tracking on July 1st, 2023.

All those accounts that didn’t manually upgrade were automatically upgraded.

The new version is definitely way better than the previous one. You get so many new things, such as better data tracking, a cleaner interface, enhanced customization capabilities, etc. Let’s explore some differences below:

Universal Analytics vs. Google Analytics 4

Here’s a quick summary of some prominent differences between Universal Analytics and GA4.

Universal Analytics

Google Analytics 4

UA only tracked page views and not the other actions viewers took in a session, such as video watching, clicks, etc. GA4 has a deeper tracking mechanism and tracks individual events such as engagements, signups, etc. Page view is just another property to track with GA4.
UA calculated bounce rates as a percentage of all sessions where users viewed only one page and triggered only one request to the Analytics server. GA4 calculates bounce rates as the percentage of sessions that were not engaged sessions. Simply put, bounce rate inversely correlates with engagement rate.
Very limited on the predictive data. GA4 utilizes advanced machine learning, which can deliver predictive results for 3 metrics: Purchase probability, Churn probability, Predicted revenue
Report pages weren’t customizable. You can customize the reports and rearrange data cards.

Other differences include:

  • Differences in the reporting interface. Several names for reports have also changed.
  • Better tracking of customer’s journey.
  • GA4 has better privacy protection for users.

Effective Tracking + High Performance = Great Magento Stores!

With Cloudways, you get the optimized Magento hosting that offers latest technologies, including Apache, Nginx, and PHP-FPM, No downtimes, high scalability, and 24/7 support!

Why Integrate GA4 with Magento?

Now, why should you pair up the GA4 with your Magento store? There are several reasons for that. Let’s look at some top ones.

1. Free Integration: Building up a Magento store itself can be a pretty costly venture. And most tracking extensions for Magento are paid. GA4 is an amazing tracking tool that’s available free of cost.

2. Better Report Flow: With UA, the path tracking of visitors was pretty limited. GA4 makes your magento analytics very pinpointed because of a better report flow. You can set endpoints for your analysis and go back to each step to track the customer journey.

3. Predictive Metrics: GA4 offers predictive analytics – a feature that is missing from several premium tracking tools. Sure, these predictions aren’t to the point, but you can get an idea of the direction where your store numbers are heading.

4. Real-time analytics: GA4 keeps track of data in real-time. And In case of anomalies, it’ll also notify you immediately so that you can monitor the data and take necessary actions.

5. You Can Build Funnels: Funnel building is a breeze with GA4. You can see how many store visitors move to different stages of your funnels and where they bounce off. This will allow you to create better funnels and eventually convert better.

6. Compatible with Web and Apps: You can now track Web, Android, and iOS data. This makes it super easy to track your Magento stores. This feature was missing in the previous version.

How to Integrate Magento with GA4

Now to the meaty part of the article. I’ll show you how to integrate GA4 with your Magento stores step-by-step for free.

1. Set up your tag manager account. Sign up on and create an account.

 create account

2. Input the necessary information and your container name, then scroll down to find the Create button. Click on it once you’ve put in the correct information.

account setup

3. You’ll get the option to accept some permissions. Click yes, and you’ll get the GTM installation codes below. Copy the <head> and <body> codes with you somewhere and keep it safe with yourself.

install tag manager

4. Then, you have to go to your Magento Dashboard. Here are the steps to follow:

Content → Configuration → Edit → HTML Head.

HTML head

edit button

5. Once in the HTML Head, copy the codes you got from the GTM. Paste the <head> in the Scripts and Style Sheets section and the <body> code in Footer → Miscellaneous HTML.

save configurations

6. Click on Save Configuration, and your work is almost done. The next step is to clear the Magento Cache:

System → Cache Management → Flush Magento Cache.

cache management

flush magento cache

7. Next, go to Google Tag Manager, and click Preview.


8. It’ll load for a while, then give you a window. Enter your site’s URL there, as shown below, and then click Connect.


9. It’ll show you a message Connected once all is done. And that’ll be the confirmation that your GA4 is integrated with your Magento store. YAYYY!

It will also open your Website page with the Tag Assistant Connected message.

10. Click Continue. And you are now ready to track your Magento Analytics!


confirmation message

Now that your Magento store is loaded with the power of GA4, you are set to use it in whichever way you want to get better analytics and tracking in place. However, I’ll help you better track your store performance by sharing some tips with you below.

Tips for Effective GA4 Tracking

Navigating GA4 can be an adventure for you if you aren’t comfortable with the platform. You may feel overwhelmed as well. But you have nothing to worry about.

But you can make your magento store tracking super effective with the right approach. Let’s see some tips below:

1. Define your Tracking Metrics

Not tracking metric that GA4 offers is relevant to your store. Ensure that you only track what’s essential for your store’s growth. Keeping eyes on irrelevant numbers will pollute your data sets and hinder you from making clearer growth decisions.

Once you’ve sorted out metrics to track, you can customize your metrics under the ‘REPORT DATA’ section.

2. Don’t sleep on Predictive Numbers

GA4 can give you insights into the future by analyzing past data for you via machine learning. You can get results for:

  • Churn Probability
  • Predicted Revenue
  • Purchase Probability

But take those numbers with a pinch of caution. Those numbers are just for an idea. Developing a strategy completely around them can be a mistake as there are several external factors to account for.

Also, you should avoid relying on it if your store is considerably new since limited data can give you highly skewed numbers.

3. Make Use of Custom Reports

You have lots of freedom to customize your reports and key metrics. Do explore this dimension of GA4 and make it relevant to your Magento stores. Explore the differences between bounce rates, sessions, customer personas, etc.

You can also create dashboards for different business goals. So, don’t just stick to default data processing. Make reports and dashboards specific to your business operations.

You can explore custom reporting under the ‘REPORT DATA’ section of GA4.

4. Track your Acquisition Sources

Know the channels that bring you traffic. You need to know where to direct your efforts and where to withdraw them from. If you don’t effectively track your traffic acquisition sources, you can very well be wasting your time and resources and losing potential customers.

Hire an expert: If you have the budget, consider hiring a GA4 expert to set up your analytics. This will make the process quicker rather than you exploring everything via trial and error.

You can even pay them once to make custom dashboards that you can track to trace your store’s performance.


GA4 is a powerful analytics tool. And it’s so easy to integrate with Magento 2 stores.

By following the steps above, you can pair up the two software and start your Magento analytics journey with GA4. However, be sure to utilize the true potential of GA4 via customization options.

Also, you can explore other Google tools, such as Ads conversion, Ads remarketing, etc., with the tag manager. So that’s it from my side. Hope you have an amazing time utilizing GA4 for your store.

Content shelf life is important.

Q. Does Magento have Analytics?

A. Yes, you can track your store’s performance on the Magento dashboard by going to the Reports section. However, those analytics can be pretty basic, and you’ll likely need advanced analytic solutions such as GA4 to enhance your performance tracking.

Q. Does Magento support GA4?

A. Magento is fully compatible with GA4; you can easily pair up the two.

Q. How to Integrate GA4 in Magento 2?

A. You can integrate GA4 with Magento 2 in three different ways:

  • Directly get the integration code from GA4 and use it with Magento 2.
  • Integrate GA4 via Google Tag Manager.
  • Integrate via paid or free extensions by developers such as Magefan, Weltpixel, Meentashi, etc.
Share your opinion in the comment section. COMMENT NOW

Share This Article

Abdul Rehman

Abdul is a tech-savvy, coffee-fueled, and creatively driven marketer who loves keeping up with the latest software updates and tech gadgets. He's also a skilled technical writer who can explain complex concepts simply for a broad audience. Abdul enjoys sharing his knowledge of the Cloud industry through user manuals, documentation, and blog posts.


Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour


  • 0


  • 0


  • 0


  • 0



For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now