Magento 2 Google Tag Manager Extension

View Demo

Add GA4 ecommerce tracking and Google Tag Manager to your Magento 2 store without editing theme code.

The extension sends 17 GA4 events, from product list views to refunds, comes with ready GTM containers for GA4 and Google Ads, and shows every event in a built-in debug toolbar.

  • Track every step from product list to purchase and refund in GA4.
  • Track clicks on any storefront element by CSS selector.
  • Send customer data for Google Ads Enhanced Conversions through GTM.
  • Gather non-standard information by adding custom dimensions and metrics.
Marketplace Approved
Hyvä
Magento Cloud
WCAG
Mage-OS
Compatible with:
Community:
2.3.* - 2.4.9
Enterprise:
2.3.* - 2.4.9
Problem

Magento Open Source sends only the purchase to GA4, and Google Tag Manager support comes only with Adobe Commerce. Tracking every step before the order means a developer builds the data layer by hand.

Solution

The extension builds the data layer (the event data GTM reads) for 17 GA4 events and gives you ready GTM containers. Paste your GTM code, import the container and check each event in the debug toolbar.

Is it worth it for your store?

What you get

All 17 GA4 events in one edition, plus Google Ads conversions and remarketing. Used by 1,000+ Magento stores.

What it takes

Minutes. We install it for free, guide you through the Google setup and check that the events arrive.

Where it stops

Ad blockers stop browser events, so GA4 may show fewer orders than Magento. For per-customer journeys, use Mixpanel.

Main features of Magento GA4 and Google Tag Manager extension

  • 17 GA4 events in a ready data layer, no theme code to edit
  • Ready GTM containers for GA4 and Google Ads to import
  • Google Ads conversion tracking and dynamic remarketing
  • Refunds and admin orders sent to GA4 server-side
  • Custom dimensions and metrics from product, customer and order attributes
  • Built-in debug toolbar that shows every event as it fires
  • Separate GTM container per store view, prices in store currency
  • Works with Luma, Hyvä (including Hyvä Checkout) and Breeze, Magento Open Source and Adobe Commerce 2.3–2.4.9

What you'll see in GA4

Where checkout loses buyers. The begin_checkout, add_shipping_info, add_payment_info and purchase events show in the Checkout journey report at which step shoppers leave.

Which campaigns pay off. Every purchase carries revenue, tax, shipping, coupon and a new or returning customer flag, so GA4 and Google Ads attribute real money to each campaign.

How segments and products perform. Customer group and product variant travel with the events, so you can split any report by wholesale and retail buyers, or by size and color.

For raw, event-level behavior analysis next to GA4 (funnels, retention and per-customer journeys), add our Magento 2 Mixpanel extension.

GA4 report built on Magento ecommerce events

Google Analytics 4 (GA4) support

The extension pushes GA4 ecommerce events to the data layer in the format Google expects, and the ready container turns them into GA4 tags. Refunds from credit memos and orders created in the admin never happen in the shopper's browser, so the extension sends them to GA4 server-side via the Measurement Protocol. All other events stay in the browser, so no purchase is counted twice. GTM server containers and Google Tag Gateway aren't supported.

Google Consent Mode v2 works together with Mirasvit GDPR Cookie Consent: it sets the ad_storage, analytics_storage, ad_user_data and ad_personalization signals, and your Google tags follow the shopper's choice. With another consent tool, set consent inside Google Tag Manager.

GA4 report with Magento ecommerce data

The extension sends these GA4 events:

Product list views view_item_list
Product list clicks select_item
Product page views view_item
Adds to wishlist add_to_wishlist
Cart views view_cart
Adds/removes from cart add_to_cart, remove_from_cart
Checkout starts begin_checkout
Shipping info add_shipping_info
Payment info add_payment_info
Purchases, including admin orders purchase
Refunds refund
Site search search
Account sign-ups sign_up
Logins and logouts login, logout
Newsletter sign-ups subscribe_newsletter

Google Ads conversions and dynamic remarketing

Add your Conversion ID and label, and every purchase is reported to Google Ads as a conversion. Every event with products carries the dynamic remarketing parameters, so your remarketing ads show the products a shopper actually viewed. The tags come in a ready container (see how to configure Google Ads).

For Enhanced Conversions, the purchase event also carries the customer's email, phone and address. You switch Enhanced Conversions on in Google Tag Manager, and the Google tag hashes the data before sending it (see how to set up Enhanced Conversions).

Why the numbers in GA4 match your store

Tracking code that only works on a clean test page breaks on a real store. The extension handles the cases that usually skew the numbers:

  • Search engine bots (Google, Bing, Baidu, Yandex) don't trigger product and category views
  • Product list views stay correct with layered navigation, AJAX pagination and cached category pages
  • Large categories are sent in batches of 30 products, within the GA4 limit per event
  • Prices can be sent in the store view currency instead of the base one
  • A command-line check builds the event data for any product and reports empty IDs, missing prices or broken values, so you can run it after catalog changes or in a deployment check

Built-in Debug Toolbar

Know exactly what information is sent to Google Analytics with every action.

Open any storefront page with ?debug=gtm and the toolbar shows each GTM event with its full data as it fires. If you also run other Mirasvit trackers, ?debug=tm shows all of them, one tab per tracker. Every event is also written to a log on the server. It works alongside Google Tag Assistant, which shows what GTM does with the same data.

Debug toolbar showing data layer events on the storefront

Custom dimensions and metrics from Magento 2 Google Analytics 4

Gain deeper insights into your customers' behavior by collecting non-standard data through custom dimensions and metrics. For example, the extension can send brand, special price, customer group, tax class, dynamic weight, payment method and other product, customer and order attributes to your Google Analytics reports.

Custom dimensions and metrics settings

Track clicks on any storefront element

Banners, custom product blocks or a size chart tab: the extension can track clicks on any element you point it to with a CSS selector, and send them to GTM along with the ecommerce events. Setting up a selector is a technical task, usually done by your developer.

Custom product block on the storefront tracked in GA4

Set up in minutes, without editing code

Paste the GTM code and the no-script code into the admin, then enter your GTM account, container and GA4 measurement IDs. The extension gives you a ready container file for GA4 and another for Google Ads, with tags, triggers and variables already filled in with your IDs. Import them into Google Tag Manager, publish, and check the events in the debug toolbar. The quick start guide walks through each step.

GTM container code fields in Magento admin

One data layer for all your pixels

GA4 and Google Ads are built in. Facebook Pixel, TikTok Pixel and Mixpanel are separate Mirasvit extensions that run on the same data layer. Add any of them and they get the same events, products and totals as GA4, while attribute mapping, event exclusions and debugging stay in one place.

Still comparing GA4 and Google Tag Manager extensions? Our comparison of the main Magento 2 GTM and GA4 extensions puts nine of them side by side on price, server-side tracking, Consent Mode v2 and Hyvä, including where another one is the better fit.

No hidden fees
Our developers install the extension on your store and configure it for your setup, free of charge.
Lifetime access to source code
Access to free support and updates for 1 year
Updates and support prolongation - $90

Pay today $149 for the first year.

Then $90 for updates and support services per year.

Cancel anytime.

30 days money back guarantee
See it in action!
Pick a quick tutorial to learn about various aspects of this extension
Customer Reviews 36
Earn points for your review about this extension modules. $1 = 10 points
Write Your Own Review

check-circle You submitted your review for moderation.

Alexander Verified Buyer
From Germany
Using the module for 2 months
Reliable tracking via GTM
Simplifies Google Tag Manager integration and makes tracking easier to manage. Runs smoothly and receives regular updates. It does what it should do.
Also installed:
Layered Navigation,  Elastic Search Ultimate,  Automatic Related Products,  Follow Up Email,  Surcharge & Additional Payment Fee
Alan
From United States
Excellent precision
I purchased this extension hoping to improve the efficiency of my Google Ads campaigns, and it worked! Mirasvit’s GTM implementation sends all the required events, allowing Google to track user behavior accurately and target ads more precisely.
RVPE Verified Buyer
From Sydney, Australia
Using the module for over 2 years
We are satisfied with Google tag management
We installed Mirasvit's Google tag management extension for Magento 2.4 and have been satisifed with the product.
Also installed:
Product Kits
Jarek Verified Buyer
From Havířov, Czechia
Using the module for over 2 years
GA4 ok, FB not working anymore.
We bought this extension to install GA4 and FB pixel, from start it was working fine, but FB pixel is not supported anymore and we need to buy another extension.
Also installed:
Automatic Related Products,  Facebook Pixel & Conversion API,  GDPR,  Product Labels,  Extended Shopping Cart Rules,  Elastic Search Ultimate,  Google PageSpeed Optimizer and 8 more
Rey Verified Buyer
From Clifton Hill, Australia
Using the module for over 1 year
It does the job. Very satisfied
Very happy with this extension and haven't had any issues with it.
Also installed:
Advanced Reports,  Custom Form Builder ,  RMA
Manual & Support
Need more help?

Save time by starting your support request online and we'll connect you to an expert.

Frequently asked questions
chevron-down chevron-right

What is the purpose of the Google Tag Manager?

Google Tag Manager (GTM) is a free Google service for managing the tracking code on your website. For an online store, it tracks events such as a product added to the cart, a product viewed in the catalog or shipping information entered at checkout.

GTM gives store owners a browser interface, so they can change tracking tags without editing the store's source code.

GTM has three main parts:

  • Tags: pieces of code, usually JavaScript, that send data to a service such as Google Analytics
  • Triggers: rules that decide when a tag runs
  • Variables: values that tags and triggers use, such as the product price

You can create a separate tag for every event you want to track. GTM then sends the collected data to services like Google Analytics, where it becomes ecommerce reports about your Magento 2 store.

chevron-down chevron-right

Why use an extension instead of Magento's built-in tracking?

Magento's own Google Tag Manager module comes only with Adobe Commerce. Magento Open Source ships the Google Gtag module instead: it connects GA4 by Measurement ID and tracks the purchase on the success page, but doesn't load a GTM container or track product, cart and checkout events.

Without an extension, a developer has to build the data layer for every event in your theme. The extension does this for 17 GA4 events, gives you ready GTM containers for GA4 and Google Ads, and sends refunds and admin orders to GA4 server-side.

chevron-down chevron-right

How do I set up the extension?

Setup takes minutes, and the free installation includes it: we install the extension, walk you through the steps in your Google accounts and check that the events arrive. The steps are:

  • Create a Google Analytics 4 property and a Google Tag Manager account
  • Paste the GTM code and the no-script code into the extension settings in the Magento admin
  • Enter your GTM account, container and GA4 measurement IDs, download the ready container and import it into Google Tag Manager
  • Publish the container and check the events in the debug toolbar

See the quick start guide for details.

chevron-down chevron-right

How do Enhanced Conversions work with this extension?

The purchase event in the data layer carries the customer's email, phone and address in the format Google expects. You turn on Enhanced Conversions for your Google Ads conversion tag in Google Tag Manager and point it to these fields; the Google tag hashes the data before sending it.

See how to set up Enhanced Conversions for the step-by-step guide.

chevron-down chevron-right

Does it support server-side tracking?

Partly. Refunds from credit memos and orders created in the admin panel never happen in the shopper's browser, so the extension sends them to GA4 server-side via the Measurement Protocol. All other events, including storefront purchases, are sent from the browser, so no purchase is counted twice.

GTM server containers and Google Tag Gateway aren't supported.

chevron-down chevron-right

Will the extension slow down my store?

Most of the weight comes from the GTM container itself and the tags you add to it, not from the extension. The extension accepts the GTM code as you paste it, so you can use a delayed version that loads GTM after the page: see how to defer Google Tag Manager.

On its side, the extension sends large product lists in batches and doesn't track search engine bots.

chevron-down chevron-right

Does it work with Consent Mode v2 and my cookie banner?

Yes. With Mirasvit GDPR Cookie Consent, the Consent Mode v2 signals (ad_storage, analytics_storage, ad_user_data and ad_personalization) are set automatically, and your Google tags follow the shopper's choice. With another consent tool, set consent inside Google Tag Manager.

chevron-down chevron-right

Does it work with Hyvä and Breeze themes?

Yes. Hyvä support is built in, with no separate compatibility module, and the shipping and payment steps are tracked in Hyvä Checkout too. Breeze storefronts are supported as well, including add to cart, product list views and checkout steps.

chevron-down chevron-right

Which events does the extension send to Google Analytics 4?

The extension sends 17 GA4 events:

  • Catalog: view_item_list, select_item, view_item, search
  • Cart and wishlist: add_to_cart, remove_from_cart, view_cart, add_to_wishlist
  • Checkout: begin_checkout, add_shipping_info, add_payment_info, purchase
  • After the order: refund, and purchase for orders created in the admin
  • Customer: sign_up, login, logout, subscribe_newsletter
chevron-down chevron-right

Which GA4 reports does the extension fill?

With these events, the standard GA4 ecommerce reports work out of the box:

  • Ecommerce purchases: views, cart additions and revenue for each product
  • Purchase journey: how many shoppers move from product view to cart, checkout and purchase
  • Checkout journey: at which checkout step shoppers leave
  • Monetization overview: total revenue and average revenue per buyer
chevron-down chevron-right

What can I send as custom dimensions?

GA4 doesn't collect store-specific data by default. With custom dimensions and metrics, you can send it from product, customer and order attributes, for example the product brand, customer group, payment method or store view.

chevron-down chevron-right

Why switch from another GTM extension?

Stores that switch to this extension usually name three reasons: it sends more data (17 events and a purchase with shipping, payment and new or returning customer details), it gives full control over what is sent (attribute mapping, custom dimensions, a JavaScript condition to switch events off), and it has a built-in debug toolbar to check every event.

chevron-down chevron-right

Does it work with Adobe Commerce B2B purchase orders?

Yes. The purchase event is also tracked on the success page of B2B purchase orders.

Changelog
Version 2.1.4Oct 9, 2026
Updating from the old separate Hyvä package (mirasvit/module-gtm-hyva) is now smoother: Composer removes it automatically instead of refusing to install this version until you uninstall it by hand
The "Download" buttons for the GA4 and Google Ads conversion GTM container files in the admin now respect admin role permissions — previously any logged-in admin user could download them, even without access to the Google Tag Manager settings
Fixed a possible error when sending events with Google Ads remarketing enabled, if the remarketing data replaced the event's ecommerce block with an unexpected value
Server-side GA4 (Measurement Protocol) requests that Google rejects now report Google's response code and validation messages, instead of throwing an error whose message could expose your GA4 API secret in log files
Version 2.1.3Sep 14, 2026
Map shipping_tier and payment_type on the GA4 purchase tag
Version 2.1.2Aug 28, 2026
Google Ads conversion tracking now records the real order value on purchase instead of a zero-value conversion
Google Ads conversion and remarketing tags are no longer blocked on stores with Content Security Policy enabled
Version 2.1.1Jun 16, 2026
Deliver login, logout, and sign_up GTM events reliably
Version 2.1.0Jun 10, 2026
Event delivery is now fully handled by the Tag Manager (Mirasvit_Tm) shared data layer — the module's own JS event stack, AJAX cart-response injection and frontend routes were removed
Server-side GA4 Measurement Protocol sending refactored into a dedicated API client
The module-specific debug toolbar and "GTM logging" option were replaced by the shared Tag Manager debug toolbar and Debug Mode setting
Updated remarketing variables in the GTM container import (gtm_conversion.json)
Hyva theme is supported out of the box — the separate mirasvit/module-gtm-hyva compatibility extension is no longer needed and must be removed
The "Tracking settings" and "Attribute mapping" options moved out of the Google Tag Manager section into the shared Tag Manager (Mirasvit_Tm) section, where they apply to every consumer module. Saved values are migrated automatically on update — please re-check your tracking configuration under Stores → Configuration → Mirasvit → Tag Manager after updating
Requires mirasvit/module-tm 1.1.0 or newer
Reasons to choose Mirasvit
Client focusing and satisfaction

These are our primary. A major portion of our new clients come from referrals from our existing clients. Our professional team of developers, marketers and support staff have invested the best knowledge and experience in the field into our work, so you know you can come back to us again and again.

Remarkable support

One year free and high quality support. We go to great lengths to provide maximum satisfaction with every module you have purchased in our store. By helping you with installation, configuration, answering your every question, we do all our best to eliminate any possible problems.

Risk-free Investment

30-days money back guarantee. If you are not satisfied with our extension performance for any reason, we provide a full refund.

Constant improvements and upgrades

We constantly add new features to all our modules, and are always interested in hearing your opinion and implementing your suggested features in our future developments.

Comprehensive Documentation

We provide an expanded user guide for every aspect of our extension, so you can find answers for all your burning questions.

Unencrypted source code of our products

You can customize extension according to your needs and requirements.

Usability and Performance

The Module is easy to install and upgrade, just follow our step-by-step user guide. Additionally, the extension is ready to use with the Hyvä theme.

Ready for Magento Cloud

No core modifications. The extension has been tested in a Magento Cloud environment and is fully compatible with it.

Loading...