{"id":1142,"date":"2020-07-27T13:31:52","date_gmt":"2020-07-27T13:31:52","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/07\/27\/how-to-add-google-tag-manager-to-magento-2\/"},"modified":"2025-07-21T17:28:57","modified_gmt":"2025-07-21T11:58:57","slug":"how-to-add-google-tag-manager-to-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/how-to-add-google-tag-manager-to-magento-2\/","title":{"rendered":"How to Add Google Tag Manager to Magento 2: Easy Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Are you tired of managing tags on your website or looking for a better way to manage them?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then, Google Tag Manager is the simplest solution to this problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using this tool, you can manage all the tags without getting pulled in different directions.&nbsp;Here, I will guide you on how to add Google Tag Manager to Magento 2.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s start.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-google-tag-manager\">What is Google Tag Manager?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/marketingplatform.google.com\/about\/tag-manager\/\" target=\"_blank\" rel=\"noreferrer noopener\">Google Tag Manager (GTM)<\/a>&nbsp;is a free tool developed by Google that allows Magento 2 store owners to manage and deploy marketing tags, and there is no need to make changes in the code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Keeping all your tags stored in one place is one of the roles, but it does come with the following advantages of adding Google Tag Manager for Magento 2:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Completely free-to-use tool<\/li>\n\n\n\n<li>Event tracking &amp; debug features<\/li>\n\n\n\n<li>You can integrate it with various content management tools<\/li>\n\n\n\n<li>Easily works with Google Analytics<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">At times, store owners get confused between Google Analytics and Google Tag Manager.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Google Tag Manager<\/strong>&nbsp;simply collects the data of the user\u2019s actions on the website, but it doesn\u2019t analyze it. It is a tag management tool.<\/li>\n\n\n\n<li><strong>Google Analytics<\/strong>&nbsp;is the tool that analyzes the data and provides detailed reports on the users\u2019 actions.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-does-gtm-work\">How Does Google Tag Manager Work?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Google Tag Manager works in three phases. Let me break it down to help you understand better:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Tag:&nbsp;<\/strong>Here, the GTM notices the event on your website. These tags keep an eye on the activities on your page.<\/li>\n\n\n\n<li><strong>Trigger:&nbsp;<\/strong>When any action triggers on a particular event, the tags get fired, and GTM stores the action with the needed information.<\/li>\n\n\n\n<li><strong>Variable:<\/strong>&nbsp;Variable goes specific. You can learn about the specific actions taken on the site with detailed information.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Now that you know the basics of Google Tag Manager. Let\u2019s see the Magento 2 Google Tag Manager Configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-add-gtm\">How to Add Google Tag Manager to Magento 2 Websites<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"create-gtm-account\">Step 1: Create a Google Tag Manager Account<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Getting started with&nbsp;<a href=\"https:\/\/marketingplatform.google.com\/about\/tag-manager\/\" target=\"_blank\" rel=\"noreferrer noopener\">Google Tag Manager&nbsp;<\/a>login. Click on \u201c<strong>Start for free<\/strong>.\u201d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After logging in with your Gmail account, you must create your Google Tag Manager Account. Write down your account name, country and select the target platform. Then,&nbsp;<strong>click on Create<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/07\/Account-stepup-700x949.png\" alt=\"Account-stepup\" class=\"wp-image-44818\" style=\"width:840px;height:auto\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"get-the-gtm-code\">Step 2: Get The GTM Code<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">There are two sections in the code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For the first one, you need to paste in the header section, and for the second one, you must paste in the body section of your Magento 2 website.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/07\/2_GTM-Installation-Code.png\" alt=\"GTM Installation Code\" class=\"wp-image-9845\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"add-gtm-code-in-magento2\">Step 3: Add Google Tag Manager Code in Magento 2<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open your Magento Admin Panel and move to&nbsp;<strong>Content &gt; Design &gt; Configuration &gt; Edit the Store View &gt; Other Settings&gt; HTML Head.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Paste the code you got from GTM for the<strong>&nbsp;&lt;head&gt;&nbsp;<\/strong>tag here.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/07\/Header-1-1-700x379.png\" alt=\"Magento 2 admin - Header section\" class=\"wp-image-44820\" style=\"width:840px;height:auto\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"add-code-in-the-footer\">Step 4: Add The Code in The Footer Section<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now move to Footer and paste the GTM code for<strong>&nbsp;&lt;body&gt;&nbsp;<\/strong>under the<strong>&nbsp;\u201c<\/strong><strong>Miscellaneous HTML.\u201d<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And click&nbsp;<strong>Save Configuration.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/07\/Footer-700x253.png\" alt=\"Miscellaneous HTML\" class=\"wp-image-44822\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"check-gtm\">&nbsp;Step 5: Check GTM From The Front End<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now, if you are wondering how to check if Google Tag Manager is working?&nbsp;Go to the front end to know if Magento 2 Google Tag Manager is up.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Open the home page and click&nbsp;<strong>CTRL + U to open view source<\/strong>. Find GTM, and you can see the code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And the Google Tag Manager is successfully added.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2020\/07\/GTM-code-700x301.png\" alt=\"Check GTM code\" class=\"wp-image-44821\"\/><\/figure>\n\n\n\n<p class=\"has-background wp-block-paragraph\" style=\"background-color:#ffede3\">Still, feeling stuck? Get help from our Magento 2 experts&nbsp;<a href=\"https:\/\/meetanshi.com\/hire-magento-developer.html\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"measure-your-efforts\">Measure Your Efforts to Make a Profitable Store<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now that you know how to add Google Tag Manager to Magento 2, you don\u2019t need to worry about tags, as GTM does automatic tag updates.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After Magento 2 GTM, the next move for you can be to add Google Analytics for comprehensive e-commerce tracking.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can turn the GA4 insights into actionable strategies to turn your visitors into customers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you tired of managing tags on your website or looking for a better way to manage them? Then, Google Tag Manager is the simplest&#8230;<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1142","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1142"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1142\/revisions"}],"predecessor-version":[{"id":18826,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1142\/revisions\/18826"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}