
Magento 2 Google Analytics 4 | GTM integration | GA4 extension
v4.7.2Track essential ecommerce metrics with Google Analytics 4

GA4 - Powering the World’s Top Websites

Track user engagement


Implement dynamic remarketing


All features
What customers say about us
Release notes
-
v4.7.2 (Magento v2.4.x)
14 April 2025
- Compatibility: Now compatible with Magento 2.4.8
- Bug Fix: Fixed cannot add to cart
- Update: User guide link of Extension
-
v4.7.0 (Magento v2.4.x)
12 August 2024
New Feature: We added Google Consent v2 for Google Analytics 4
-
v4.6.1 (Magento v2.4.x)
03 May 2024
- Compatibility: The extension is now compatible with Magento 2.4.7
- New Feature: We added to show Event for Facebook Pixel
-
v4.6.0 (Magento v2.4.x)
26 December 2023
- New Feature: We added “Show Events” field into group “Google Analytics 4”
- Compatibility: The extension is now compatible with PHP 8.1
- Compatibility: The extension is now compatible with Mageplaza GDPR in Ga4
- New Update: We updated config
- New Update: We updated the following event add to cart, remove from cart
- New Update: We updated event add to wish list, event Customer Login After, event Order refund, event Add shipping, event Add Payment, event add_to_cart for “add all to cart” wishlist, Search event in Ga4 and FB Pixel
- New Update: We updated Custom Dimensions, and Custom Metrics in Ga4
- New Update: We updated Track Impressions and Clicks By Position in Ga4
- New Update: We updated the missing code of the event Customer Login After in GA4
- New Update: We updated compa event add_to_cart with module Mageplaza Osc in GA4
- New Update: We updated the template for the new event
-
v4.5.0 (Magento v2.4.x)
23 March 2023
- Compatibility: The extension is now compatible with Magento 2.4.6
- New Feature: We added track product impressions and click by position in the Related, Up-sell, and Cross-sell section
- New Feature: We added track product impressions and click by position in the Advanced Result Page
-
v4.4.4 (Magento v2.4.x)
30 January 2023
- Compatibility: The extension is now compatible with Magento 2.4.5
- Bug Fix: We fixed a minor bug which Datalayer
-
v4.4.3 (Magento v2.4.x)
04 November 2022
- New Update: We added setup database schema XML
-
v4.4.2 (Magento v2.4.x)
07 September 2022
- Compatible with Magento v2.4.5
-
v4.4.1 (Magento v2.4.x)
17 August 2022
Fixed minor bugs
-
v2.6.1 (Magento v2.3.x)
17 August 2022
Fixed minor bugs
-
v4.4.0 (Magento v2.4.x)
29 July 2022
- New feature: create & export tag, trigger, variables
-
v2.6.0 (Magento v2.3.x)
29 July 2022
- New feature: create & export tag, trigger, variables
-
v4.3.1 (Magento v2.4.x)
09 June 2022
- Compatible with Magento v2.4.4
-
v4.3.0 (Magento v2.4.x)
15 April 2022
- Added Google Analytics Opt out
- Added Tracking custom dimensions and metrics
- Compatible with Mageplaza GDPR
-
v2.5.0 (Magento v2.3.x)
15 April 2022
- Added Google Analytics Opt out
- Added Tracking custom dimensions and metrics
- Compatible with Mageplaza GDPR
-
v2.4.0 (Magento v2.3.x)
28 February 2022
- Supported RestAPI & GraphQL
- Added Advanced Matching & Add To Wishlist event for Facebook Pixel
- Fix minor bugs
-
v4.2.0 (Magento v2.4.x)
28 February 2022
- Supported RestAPI & GraphQL
- Added Advanced Matching & Add To Wishlist event for Facebook Pixel
- Compatible with Magento v2.4.3-p1
- Fix minor bugs
-
v4.1.3 (Magento v2.4.x)
26 October 2021
- Compatible with Magento v2.4.3
-
v4.1.2 (Magento v2.4.x)
10 August 2021
- Fixed minor bugs
-
v2.3.2 (Magento v2.3.x)
10 August 2021
- Fixed minor bugs
Frequently Asked Questions
There are two ways to integrate Google Analytics 4 (GA4) into your Magento 2 store. The first option involves manually adding the GA4 tracking code to your website's HTML head. However, this method can be complex and requires technical expertise. The second method, which is simpler and faster, involves using a GA4 extension. Below are the steps to help you integrate GA4 with Magento 2 using the extension method:
Step 1: Create GA4 Property
- Go to Google Analytics and follow the instructions to create your GA4 account
- Accept the Terms of Service
- Choose your business platform: website/app
- Enter your Website URL and its Stream name
Step 2: Get Measurement ID
- After creating a GA4 property, you’ll be redirected to the Web Stream details
- Copy the Measurement ID from this page
Step 3: Create a GTM Account and Container
- Visit Google Tag Manager > press Create Account
- Fill out the account and container details and click Create
Step 4: Find the Account ID and Container ID
- Account ID: 2 ways to locate account ID
+ Option 1: Look at the URL of your GTM container home page (also Work Space Tab), the account ID is the number right after /accounts/
+ Option 2: Navigate to Admin tab > open Account Settings > copy account ID above the Account Name
- Container ID: Similar to Account ID, the Container ID shows up in different places. However, it’s easier to spot since this ID follow a format: GTM-XXXXXXXX
+ Option 1: At the GTM Work Space tab: On the left of Workspace Channel
+ Option 2: At the Versions tab: Next to your website URL on the top left
+ Option 3: At the Admin tab: Next to your website URL in the top right
Step 5: Add GA4 to Magento 2 Store
- Go to the admin backend > Stores > Configuration > Mageplaza Extensions > Google Tag Manager
- Paste the container ID you got earlier in the Google Tag ID field and save your configuration
- Don’t forget to double check if GA4 is successfully integrated to your store
The Magento 2 GA4 data layer is a structured and secured way to collect and send eCommerce events, user engagement, and conversion data from your Magento 2 store to GA4. It helps merchants gain more in-depth analysis of customer behavior, evaluate marketing campaigns, and improve your business performance effectively.
Yes, Magento 2 has built-in analytics but they are just basic insights on customer, order, and sales. To truely understand and evaluate how your business is performing, you need advanced analytic tools like GA4 - which is not integrated in default Magento.
GA4 provides advanced tracking of customer behavior, events, and conversions, allowing you to gain detailed reports on product performance, cart abandonment, user engagement, and so on. It also offers cross-platform tracking, AI-driven insights, and integration with Google Ads for better marketing optimization. In short, integrating GA4 enables you to make data-driven decisions and optimize your store’s performance effectively.
To upload Magento extension via ZIP/Archive for GA4 extension installation, follow our step-by-step guidance below:
Step 1: Download SFTP clients
- Highly recommend: FileZilla or WinSCP
Step 2: Download the extension package
- After you bought the Magento 2 Google Analytics 4 extension, it’s time to download its package from your account dashboard
- Log in (via User-Password or Social accounts)
- Access your licenses and download the module package
Step 3: Download the Mageplaza_Core module
- Clone or download from https://github.com/mageplaza/module-core
- Run the following command in Magento 2 root folder to install Mageplaza core:composer require mageplaza/module-core
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
Step 4: Upload files to your server
- Extract the package
- Connect it to your server using SFTP Clients above
- Upload files and folders to your server
- Upload the app folder to Magento 2 root folder
Step 5: Run this command linephp bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
Let’s take Mageplaza for an example! Here's how to install GA4 extension for your Magento store through composer:
Step 1: Login and get Access Keys
- Log in to your Mageplaza account, go to My Account > My Access Key > create new Access Keys
- Enter your Key Name and then the system will auto generate unique access keys for you
- Note that: User name is the public key and password is the private key
Step 2: Install the Google Analytics 4 extension
- If it’s your first time installing Mageplaza extension, run this command: composer config repositories.mageplaza composer https://repo.mageplaza.com
- Then, run: composer require mageplaza/module-google-tag-manager
- Next, insert the access keys you created in step 1 (They’re required for Mageplaza Authentification)
- Now, you’ll see a request of Store Credential Authentification > type Y to save the Credential for settings later
- Finally, run this command:php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
Installing verified modules from Adobe Marketplace is a safe and easy choice. All you have to do is:
- Get your access keys by: Go to My Account > My Access Key > create new Access Keys > enter your Key Name and the new access keys will be auto-generated
- Install GA4 extension run the following command line (example from Mageplaza):composer require mageplaza/module-google-tag-manager
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
And that’s it!
It's a common need to upgrade your module to the latest version that the vendor releases, but many merchants struggle with conflicts. Try the following steps to guarantee a smooth Google Analytics plugin update for your Magento store:
Step 1: Navigate to your Google Tag Manager account and remove all tags that associate with the extension.
- (Because the new version may include new tags or adjustments to current tags. If you don't remove them, they can't be updated properly.)
Step 2: Eliminate unnecessary files from the old extension version.
- It's best to keep only the latest version of the files.
Step 3: Install the new upgraded module as usual.
Besides other steps of integrating GA4 to Magento, there are certain steps to follow if you want to set up checkout behavior tracking with GA4:
- Go to Google Analytics 4 > Admin > Data Streams and select your existing stream or create a new one.
- Enable Enhanced Measurement to automatically track basic interactions like page views, scrolls, and clicks.
- Create Custom Events for specific checkout tracking. Define the event name, parameters, operator, and value to track key actions.
For example, to track successful checkout actions, create a custom event as follows:
+ Custom event name: success_purchase
+ Parameter: page_location
+ Operator: contains
+ Value: /checkout/success/
- Test and verify the setup by checking GA4’s real-time reports or using Google Tag Assistant to ensure events are firing correctly.
Linking your Google Ads account with Google Analytics 4 lets you track the full customer journey—from interactions with your ads (such as impressions and clicks) to how they complete goals on your site, like making purchases or consuming content. This integration allows you to view both ad and site performance data in Google Ads reports within Analytics.
Steps to link GA4 with Google Ads:
- Go to Google Analytics 4 > Admin > Product links > Google Ads Links
- Click the Link button to begin connecting your GA4 property with Google Ads
- Select the Google Ads account you wish to link
- Configure how Google Ads works: Enable/Disable these options:
+ Personalized Advertising
+ Auto-Tagging: Recommend enabling auto-tagging on selected Google Ads accounts
+ Allow access to Analytics features within Google Ads
- Review and submit your request: Note that it might take up to 24 hours for your Google Ads link to begin displaying data
Custom Dimensions and Metrics in GA4 allow you to collect and analyze data tailored to your business needs. These features enable you to track specific attributes and quantitative data that aren't captured by default. To set up custom dimensions and metrics, follow these steps:
Steps to create Custom Dimensions and Metrics:
- Go to Google Analytics > Admin > Custom definitions
- Now you’ll see the Custom Dimensions and Custom Metrics tabs
- Press the Create custom dimension or Create custom metric button
- Enter a name for your custom dimension or metric
- Select the scope: Choose whether the dimension/metric applies to the User, Session, or Event
- Provide a description to clarify the purpose of the custom dimension or metric
- Add parameter: Specify the parameter (e.g., user_type, product_category) to capture
- For Custom Metrics, specify the Unit of Measurement (e.g., seconds/hours for time, feet/miles for distance) to define how the metric will be measured.
The Cookie Restriction mode may stop the extension from tracking the users from your site unless they accept the cookie. This applies to all actions the users engage in on your website, even placing orders. Therefore, you may find a number of orders to stay untracked.
It might take up to 48 hours to start flowing your data into Google Analytics 4. While waiting, you can double-check to ensure the configuration process from the product page is correct.
We don't recommend you to do so. Instead, it would be better to create a new GTM container for your new tags.
Yes, Google Analytics 4 is compatible with Hyva theme. However, the checkout only supports hyva-themes/magento2-theme-fallback. To learn how to enable checkout on Hyva, please follow this guide.
Mageplaza provides FREE Hyva Checkout Compatibility for all of our extensions upon requests. You can request by contacting us via email, live chat, or support ticket. Our team will respond within 24 hours and ask for details such as Order ID, extension name, Magento & Hyva versions, and any special requirements. To qualify, your module subscription must be active. If your subscription has expired, renewal is required as some older modules do not support Hyva. Additional customization requests may incur extra costs, and our team will inform you before proceeding. For assistance, feel free to reach out - we're here to help!
Pricing
Community
$134.1 (Enterprise/ Magento Cloud