New Module: Google Tag Manager for Magento 2

A Magento 2 store can get a boost by analyzing bottlenecks in its shopping process. Data is being constantly generated by its customers, and the powerful analytic toolset of Google Analytics is available for free to analyze this data.

The missing link is how to connect a Magento 2 store to Google Analytics to get enhanced ecommerce reports. The answer is the new Google Tag Manager extension. It will help to get profound analysis of customer in-store behavior without deep technical knowledge.

The extension requires little initial configuration, and after that, it simply works on its own, providing data for enhanced reports in Google Analytics. This article elaborates on the extension in detail:

  1. What is Google Tag Manager

  2. Business value of the module

  3. What problems the module solves

  4. Summary

What is Google Tag Manager?

Standard reports that Magento provides to store owners, namely Product Views, Products in Carts, Orders Report, Top Search Terms and others, are often not enough to get a clear picture of what is actually happening in the store.

Basic reports show a summary of events during some time period, but they don't allow you to track the exact customer's path that leads to purchase or cart abandonment.

Knowing a customer's path inside the store is an invaluable feature for improving marketing efforts and maximizing ROI.

Tracking of customer in-store behavior can be done through Tags. They are special snippets of code that track the event they are configured for, and provide data for extended analytics.

Here is an example of a webpage without any tracking tag:

                <title>Sample HTML File</title>
                Paste your conversion tracking tag here.

After adding tracking tag, the source code of this page transforms into this code:

                <title>Sample HTML File</title>
                <!-- Google Code for Purchase Conversion Page -->
                <script type="text/javascript"> 
                /* <![CDATA[ */
                var google_conversion_id = 1234567890;
                var google_conversion_label = "xxx-XXx1xXXX123X1xX";
                var google_remarketing_only = "false"
                        var google_conversion_value = 10.0;
                        var google_conversion_currency = "USD"
                /* ]]> */ 
                <script type="text/javascript" 
                <img height=1 width=1 border=0 

Embedding Tags into a store source code requires deep technical knowledge and it may complicate store support in future. Tag execution can also slow down the online store.

The main issues with Tags can be mitigated by using a third-party Tag managing service. Google provides such a service for free, which is known as Google Tag Manager (GTM).

It provides a convenient web interface for managing Tags, adding them to the site. Google Tag Manager transfers all collected data on in-store events to Google Analytics, Google Enhanced Ecommerce and other reporting solutions.

In order to use Google Tag Manager and Google Analytics, it is required to get accounts in both of these services.

Business value of the module

A default Magento platform provides Google Tag Manager integration only for the Magento Commerce version. The free, and therefore, much more popular Magento Open Source version does not include Google Tag Manager integration.

Store owners that use Magento Open Source can embed Google Tag Manager by editing the source code of the store, which requires deep technical knowledge. It also may increase risk of problems in the future when a new Magento version will update modified files.

With Google Tag Manager extension from Mirasvit, marketers get the ability to add tags without asking for the help of webmasters. Those tags will serve as a data source for Google Analytics Enhanced Ecommerce reports.

Enhanced Ecommerce allows you to get a deep in-store traffic analysis, learn customer behavior in detail, and make corresponding marketing corrections to boost sales in the store and increase ROI.


Using the Google Tag Manager extension, a store owner gets the ability to track almost every action a customer makes in a store. It is an easy tool to embed, which opens access to Google Universal Analytics and Google Analytics 4 enhanced ecommerce reports.

Module benefits

By installing a Google Tag Manager extension, a Magento 2 store gets access to detailed tracking of customer actions during his shopping process. This module brings a number of benefits:

See steps of customer's shopping journey

Ecommerce Tracking that becomes available when using Google Tag Manager module, allows you to see what products customers are viewing in Google Analytics. You will know when he or she adds or removes items from the shopping cart, etc. This information is key to enhancing marketing strategy and your store's design.

Google Analytics 4 (GA4) support

You can easily implement all available Google Universal Analytics and Google Analytics 4 (GA4) eCommerce reporting features in your store.

Get the support of all standard ecommerce tags and track such customer actions as product/item list views/impressions, product/item list clicks, product/item detail views. Additionally, a store owner can track when customer adds payment and shipping info.

Standard ecommerce tracking tags also allow you to monitor when a shopper adds or removes items from a cart, makes checkouts and purchases, views and clicks on promotions, and adds items to a wishlist.

Custom dimensions and metrics

You are not limited to standard tracking tags. With our extension, you can send almost any information available on the page of your store to Google Analytics.

Add custom dimensions and metrics to monitor special prices, SKUs, Tax class, item dynamic weight and other product attributes to make your Google Analytics reports more valuable. Additionally, you can track brands, product variants, and customer groups.


What problems the module solves

The Google Tag Manager extension solves the problem of getting Enhanced eCommerce reports without deep technical knowledge and code editing.

Get answers to complex questions

When Universal Analytics and Google Analytics 4 get data through Google Tag Manager, these analytic services can provide answers to some complex questions.

A store owner will get enhanced ecommerce reports that will help them find answers to such questions as:

  • what products have the best conversion rate when proposed as upsell or cross-sell
  • which categories of the store get most visits
  • what number of reviews and what review score begins increasing sales of a particular product
  • how to understand which promotion channel works best by analyzing coupons usage
  • whether customers abandon checkout cart because they are stuck in the store design layout
  • which promotional banners are most effective in your store

Easy connection to Universal Analytics and Google Analytics 4

Data collecting for Enhanced Ecommerce can be implemented in your store within several minutes. Tracking tags are created with one click in your Google Analytics and Google Tag Manager and synchronized with your store.

Any ecommerce website will find Google Tag Manager an important tool because tracking tags should be updated regularly, and GTM service does it automatically.

No coding required

With the Google Tag Manager extension, adding GTM service to your store is as simple as copy-pasting. You will not be required to edit the source code of your store to add GTM code snippet.


Without the Google Tag Manager module, you will need to edit several phtml templates of your design theme and figure out how to load them on your store frontend.

Track custom blocks in Google Analytics

Google Tag Manager extension is a tool you need if you want to get statistics on custom blocks with products in your store. Find out when a user is shown items or offerings and when he or she selects one of the proposed products in such block.

With our extension, you can push such data to Google Analytics as view_item_list, view_item and select_item for custom block tracking. It can be, for example, a custom block of cross-sell products.

No negative influence on store performance

Get in-depth analytics without sacrificing the store loading speed by gathering the data. GTM service can have a positive impact on the store performance.

Tracking tags execution requires some processing power, and if tags are directly embedded into the source code of the store, they may slow down the page loading speed. Longer page loading may lead to the bounce rate increase, and conversion rate drops.

Using GTM service allows you to execute tags on Google’s third-party servers, thus keeping the performance of your store intact.

Reduce support cost

Adding tracking tags to the store analytics manually means updating programmatic code on each page of the store. It can be rather time consuming even for small stores, and too expensive for large stores.

Additionally, the process of manual tag adding may require regular payments for developer services, who will be responsible for updating the store source code to keep tracking tags up to date.

Google Tag Manager extension can be used by non-developers, who can be a store owner, marketer, or store staff. They will be able to add and update tracking tags through convenient web interface.

Using Google Tag Manager extension in a Magento 2 store can bring huge savings of time and finances in the long run.

Debug toolbar

In case of data gathering problems, our module provides a debug toolbar to monitor issues with tracking customers actions.


The debug toolbar provided by our module allows you to see exactly what data is transferred to Google Analytics on every action that is set for tracking.


Google provides all the tools an eCommerce business may require for accurate tracking of its performance indicators. Store owners can monitor performance indicators through Google’s Universal Analytics and Google Analytics 4.

Google also provides a convenient service for collecting data for its analytic services - Google Tag Manager. Connecting Magento 2 store to this service is an easy task if a dedicated extension is used. In that case, connecting your store to enhanced ecommerce reports takes no longer than the several minutes which are required to copy-paste the authorization info.

With the Google Tag Manager extension, you can locate bottlenecks in the shopping process of your store. It is a useful tool for any store which is looking to improve marketing efficiency by finding answers to important marketing questions. And all this is done without requesting the help of developers, which lowers store support costs in the long run.

Eugen Barilyuk


Eugen, a tech-savvy writer at an IT company. He spends his days simplifying complicated tech stuff into easy-to-read blog posts and documentation. Eugen loves blending his love for tech with storytelling, making complex topics not only understandable but interesting. Beyond work, he enjoys exploring the creative side of technology and innovation.