How to add & config GTM (Google Tag Manager) in Magento 2

Jade avatar
Jade Updated: March 01, 2023


The Most Popular Extension Builder for Magento 2

With a big catalog of 234+ extensions for your online store

Google Tag Manager (GTM) is a free Google marketing tag management tool that allows you to update and track codes automatically to get more accurate analytics data. As managing tags manually is complex and time-consuming, this solution is provided to handle everything automatically for better evaluation and decision-making processes.

But how can you experience all these benefits to the fullest? The answer is to add Google Tag Manager to Magento 2. When this tool is integrated into your backend, you can gain more control over your store tags.

In this article, I will review and explain more about Google Tag Manager for Magento 2. Let’s learn how you can add Google Tag Manager to Magento 2 and configure it via a third party!

Google Tag Manager

Google Tag Manager Extension for Magento 2

A clear insight into shopping and behavior of customers with 5 advanced reports Learn more

Table of contents

What is Google Tag Manager?

Due to the existing disadvantages mentioned above, Google Tag Manager(GTM) is a free tool provided by Google. This tool is very effective, as the management activities will all happen in the Google Tag Manager system rather than editing site code. The tools bring numerous valuable benefits:

  • Help marketers to control the marketing campaign
  • Reduce errors when creating and updating tags
  • Deploy tags quickly
  • Free you from having involved with Webmaster

In addition, the tool can work with both Google tags and non-Google tags, which can be related to Facebook Pixel, Bing UET, or other third-party JavaScript to your site using Google Tag Manager. Right after you add Google Tag Manager to Magento 2, you can set up Google analytics and other supportive tools to track and report the website traffic.

To learn more about third-party services integration, you should keep reading more about Magento 2 Google Tag Manager.

What is a tag?

Tags are snippets of code which is added to your site to collect information and send it to third parties. Tags play the role of the optimizer for your site marketing activities by measuring your site traffic with ease

For a normal site, there is an abundance of tags attached which needs to be managed by a complex amount of code. Managing tags is an activity that consumes a lot of time. As a result, managing too many tags can make admins feel overloaded when it always requires them to create new tags and update old ones.

The consequence of tag overload will damage your store revenue. Besides, it can delay the marketing campaign due to the time-consuming activities of tags management. It can put your campaign on hold for a few weeks or even months which prevents store opportunities to boost sales.

How does GTM work?

Google Tag Manager process

Based on Psyberware, the writer clearly clarifies the GTM process in 3 main stages: Firstly, the event is a condition that possibly can occur on a website. The second stage triggers a response when the set event happens. And, the tag will do certain actions on a third party site.

For example, when you activate an analytics tag when a user loads a new page, the customer clicks on webpages will be an Event that will match with Page Trigger. After that, the trigger will notify that the page is loaded to fire the analytics tag.

Why you need Magento 2 Google Tag Manager

Despite the Magento 2 Enterprise edition has already contained Google Tag Manager, the Open Source version is NOT fully geared with this GMT. This defect can prevent you from getting the benefits that your store could have. However, you can consider to integrate it into your store sites with a Google Tag Manager module. The significant benefits can be named:

Centralize Google Tag management system

With the help of the Mageplaza Magento 2 Google Tag Manager extension, stores can enjoy managing tags directly in the store site system. All the messy tags will be generated and upgraded easily. By keeping all the information in one system, stores organize data with ease.

Enhance the site’s performance

Many codes being added to the source of store sites are one of the contributing reasons that slow down the page’s loading speed. And, a website with a slow loading page will increase the bounce rate, and lower conversion rate. If you want to prevent the issue in the first place or mitigate the disadvantage, an optimal solution is to add Google Tag Manager to Magento 2. With the assistant of the GTM codes, you can save more time for page loading by controlling all the script-tags and you only need to insert it into your sites. With a few seconds optimized for websites speed, your client expectation can be fulfilled and increase conversion rate.

Reduce cost in the long term

The simplified working process provided by GTM will help non-developers like store owners and marketers take the initiative to control the tags themselves. With less involved people, the store can save budget spending on hiring the developers. Time to maintain the extension and configuring basic codes will be a huge saving in the long term operation. Even when hiring a developer who takes care of GTM settings, it enables ecommerce businesses to make a faster process and still generate your savings.

Generate reports and analytics with Google Analytics

Google Analytics (GA) is another free tool provided by Google with the aim to create reports, statistics on your websites. Despite Google Analytics and Google Tag Manager can work separately from each other, GTM can act as a middleman to simplify data analytics process. Setting up GA through GTM will bring many benefits to your ecommerce business:

  • Simplify the code in place on your store sites
  • Edit setting without development updates
  • Set up advanced features easier like domain tracking

Overall, you can gain better performance when integrating two of these tools together. Or, you can simply implement Google Tag Manager extension which also features Google Analytics and Facebook Pixel.

Create automatic remarketing campaigns with Google Adwords

Google Adwords remarketing can be enabled when you add Google Tag Manager to Magento 2. Mageplaza Google Tag Manager extension includes Google functionalities that your store needs, and to optimize remarketing, it is essential to have an automatic system to track and display the relevant ads.
The adwords conversion tracking is useful for you to measure efficiency and build future marketing strategies.

How to add Google Tag Manager to Magento 2 store

It is possible for you to integrate this gadget without a middleman like an additional module. However, activating integration is quite a bothersome task when compared with installing a module. Besides, Magento 2 Google Tag Manager extension by Mageplaza also features with many more functionalities that await you to install to the store backend.

First off, before getting back to the Magento admin panel, you should register a Google Tag Manager account via this link here.

Register a Google Tag Manager account

Then, input the required information for the registration process for your account.

add a new account

You can set up the “container”. The container is a set of rules, tags and macros which is configured for a specific site. You should fill the container with your website’s domain name. For stores that have multiple store sites, you will have to create several containers. Also, you should set it as “Web” Container as you are running a website, not a mobile app. Then, click Create.

After that, you can copy the code generated by the GTM system like below and paste it into each page of your store site.

Code generated by CTM system

Finally, you can access the Admin section to collect Container ID to install in Magento

Admin section

How to configure Magento 2 Google Tag Manager

When you already add Google Tag Manager to Magento 2, now it’s time to configure the module:

General Configuration

You need to come back to the Magento Admin, choose Stores > Configuration > Mageplaza Extensions > Google Tag Manager. In the top field, select Yes in Enable field to activate the extension.

general configuration

Configure Google Tag Manager

configure Google Tag Manager

Next, select Yes in the second Enable field to enable the use of the Google Tag Manager feature which helps to update and control all tags on the site.

For the Google Tag ID field, admins need to paste the Google Tag Manager’s Container ID to this field to update some information on an event. The event can be set in category page, product page, when adding to cart, remove from cart, order success, search, checkout default or checkout page of Single page Checkout extensions which help shorten checkout process to only 6 steps within a page and optimize the checkout process for customers.

If the field is left blank or filled with incorrect information, the Container ID will unable to display information in detail.

Tag manager

Note: You can activate the Google Tag Manager by creating Trigger then Tag and click Preview or Submit in case GTM is disabled.

trigger configuration

Now, if you want to configure Google Adwords for adwords conversion tracking, Google Analytics Enhanced Commerce, and Facebook Pixel to your store, please refer to this full user guide.

Final words

In a nutshell, Google Tag Manager extension provided by Mageplaza is the optimal solution which can help to reduce the number of the installed module. The module not only provides the function to manage tags for store sites but also provides Google Adwords, Facebook tracking, Google Analytics within this module. With 4 of these tools all included in the GTM extension, you can manage all of them through the site. Hence, if you find it difficult to add Google Tag Manager to Magento 2, Mageplaza support team will help you install the plugin to your Magento 2 store sites.

Google Tag Manager

Google Tag Manager Extension for Magento 2

A clear insight into shopping and behavior of customers with 5 advanced reports Learn more

Magento Support
& Maintenance Services

Make sure your M2 store is not only in good shape but also thriving with a professional team yet at an affordable price.

Get Started
avada marketing automation

Jade is a content creator, book lover, and a hodophile. She loves to learn skills and practical knowledge to excel at marketing, especially content marketing.

People also searched for


Stay in the know

Get special offers on the latest news from Mageplaza.

Earn $10 in reward now!

Earn $10 in reward now!

go up