How to set up Google Tag Manager on Shopify (+2022 Updates)
Tags: googletagmanager, shopify, tutorial, analytics
Published: 2021-03-02 09:23:06

Google Tag Manager(also known as GTM) is one of the most influential and useful tools for marketers, entrepreneurs, developers, and many others. However, Shopify doesn't have a native integration for GTM and it is a little tricky to set it up. 

> Update (11.12.2022) 🎉 We are excited to announce the release of our updated guide on setting up Google Tag Manager on Shopify. This new version includes the latest updates and improved methods for setting up Google Tag Manager on your Shopify store. To access the guide, please visit the following link: [How to set up Google Tag Manager on Shopify](https://dev.to/ekuplu/how-to-set-up-google-tag-manager-on-shopify-data-layers-16j5). 

We hope this guide will help you easily implement Tag Manager on your store and improve your tracking and analysis capabilities. 

> Update (17.04.2022) We have made an in-depth update on our tutorial series and also included data layers for product - purchase pages, GTM container and more. Check out our latest tutorial: [Set up GTM on Shopify [2022 Edition]](https://analyzify.app/google-tag-manager-shopify/setup). 


> Update (23.03.2021) This tutorial explains how to add GTM into Shopify directly. We have made a new - free [Shopify - Google Tag Manager video course series](https://www.youtube.com/watch?v=S-Nz8dOxgE8&list=PL92pEp_0XVLpEse3d2i-zv034Vyi64gmF&index=2) on Youtube. Check out the video series if you want to further expand your data-analytics setup.


## Why use Google Tag Manager on Shopify
Google Tag Manager allows us to manage all the marketing and tracking tags from one place, deploy and test quickly. Without using the GTM, marketers need developers to set up the tags - and even it isn't very easy for developers to set up certain tags in certain conditions. As a concrete example, you need to add the Google Analytics Global tag to all pages, the purchase event to thank you page, the form submission event to be triggered once the form is submitted correctly. All of them can be done quickly in GTM within minutes. I can count the benefits of GTM for hours, but the topic is now how to add the Google Tag Manager into your Shopify store. 

## Shopify - Google Tag Manager Integration
Shopify doesn't have a native integration with the GTM. There are two methods to add the Google Tag Manager container (code) into the Shopify stores. We will add the code manually into your Shopify store's theme and checkout files in the first method. In the second method, we will review a few Shopify apps that do the integration for you. 

### Method 1: Adding GTM into the Shopify Theme
It might not sound effortless, but it is actually quite applicable. We will walk you through the steps, and you will easily be able to add Google Tag Manager to your Shopify store. Follow the steps below, and don't miss the last step. Otherwise, the code won't be triggered on your thank you page, which is very important. 

#### Step 1: Get your GTM Container Code
Register for Google Tag Manager if you are not registered already. You can follow this [simple tutorial](https://www.youtube.com/watch?v=R4UQLtHrebo&t=9s&ab_channel=Analyzify-PowerfulShopifyAnalytics) if you don't have an account yet. Once you are logged in to your account, click your GTM ID at the top of the screen and copy the given code below. 
![Google Tag Manager Code for Shopify](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/esxl2n97lzd8x8pu4x47.jpg)
Copy the first code. Don't mind about the second code. That's rarely needed, and it will complicate the setup of your store. Once you make sure to copy the first container code - move to the second code. 

#### Step 2: Insert GTM code into Your Theme Files
As we have your Google Tag Manager Container code in place, it is now time to place it into your Shopify store. You need to be logged in to your Shopify admin to do so. 
Shopify Admin > Online Store (Left Menu) > Actions (Near your theme name) > Edit Code
![Add GTM into Shopify theme Files - 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3urvvjk7dgu8etszv2y.jpg)

Search "theme.liquid" on the left search bar and find <head> tag within the file. Paste the GTM container right below the <head> tag. 
![Add GTM into Shopify theme Files - 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ih7f6x9dt434nsmkfy1c.jpg)

Now the GTM code will be shown on every page in your store except for the checkout processing and thank-you pages. 

An important note: If you are using a page builder plugin, you need to paste the code within those liquid files. 

#### Step 3: Insert GTM code into Your Checkout Processing Page
Shopify's basic plans won't allow you to edit the checkout process and add codes there. But you can still add codes on the "order completed" page. This is a crucial step because you want to track purchases in your Shopify store. 
Follow the steps below to find the Order Processing section.
Shopify Admin > Settings > Checkout > Order Processing Section
and then paste your GTM container code there. 

![Add GTM into Shopify Checkout](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/posbqva64mv91w5atwb9.jpg)

Now we are set. The GTM will work on your store pages and also on the thank you page. Let us remind you again that it won't work in the checkout steps (where the user enters their credit card and address information) - but it will still work on the order completed page. 

#### Step 4: Validate if the GTM is working
With the data-related works, you always have to double-check and validate. GTM has a great tool called Debugger (also known as Preview & Debug Tool or Google Tag Assistant) to show you if the GTM works on your store and which tags/triggers are working. 
- Go back to your Google Tag Manager interface and find PREVIEW from the right-top corner. 
![GTM Preview Mode Button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ikv0ej99ff8y5edv21p.jpg)
- Enter your store's URL and click Start
![GTM Tag Assistant](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwnlxy3lg0owehwh3rfb.jpg)
- It should open your store in a new window. Make sure that your browser is not blocking the pop-up. If yes, firstly allow it. You should see DEBUGGER CONNECTED at the right-bottom of the screen. 
![GTM Debugger Connected](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/csk3bf902iyo95cu952k.jpg)
- Go back to Tag Assistant, and you should be seeing the "CONNECTED" message here and the TAGS in your GTM account. 
![Tag Assistant Connected](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlw8u0245ifzpka267cy.jpg)

### Method 2: Using a Shopify App for Google Tag Manager
The second option is using an app to add Google Tag Manager into your Shopify store. There are several apps in the market. 

If you only need the GTM container, you do not need to use an app. Method 1 will work great for you. The apps are doing the same steps that we walked you through to make the GTM working on your store. If you are looking for an in-depth tracking setup, then we definitely recommend using an app. Because the apps will also insert dataLayers into your store, allowing you to track more actions such as product impressions, add-to-cart events, search listing actions, checkout process, remove from cart, user ID, and many others.  

The app we developed, [Analyzify](https://analyzify.app) does the following (and even more) for your store: 
* Add advanced dataLayers to track all essential actions
* Provides you a complete GTM container that has all the triggers, tags, and many others,
* Sets up Google Analytics 4 with all-important e-commerce features store (Learn more about [GA4 for Shopify](https://analyzify.app/shopify-google-analytics/ga4))
* Provides custom setup support(at no extra cost), 
* Creates precious user metrics such as User ID, User Recency, User Type, User Lifetime value, and many others, 
* Sets up Facebook Pixel and all related events, 
* Sets up Google Ads conversion tracking and all related remarketing events

Analyzify is not the only solution in the Shopify app store. There are other cool apps as well. Make sure to check each of them before you make your decision!

## Google Tag Manager without Shopify Plus
We keep receiving this question from Shopify community: "Can I use Google Tag Manager without Shopify Plus plan?" The answer is short: **you definitely can** - and 1000s of Shopify merchants are already using GTM with regular Shopify plans. There will only be a limitation: 

> You will not be able to add your GTM container into checkout pages as you don't have the checkout.liquid file. However, your GTM setup will still work on all other pages + order complete pages. That means you can still track 95% of your page visits including the most important e-commerce events. 

In other words, if you are running a Shopify Plus store; your GTM script will be running during the visitor's checkout process as well. Without the Shopify Plus plan, it will be interrupted during the checkout steps (where the user enters their credit card, address, etc information) and then be loaded back on the thank you page. 

## FAQ on Shopify & Google Tag Manager Integration 

I wanted to collect here some of the most commonly asked questions on Shopify & GTM topic. 

### How can I set up enhanced e-commmerce on Shopify using Google Tag Manager? 
Shopify merchants are often confused about the enhanced e-commmerce (aka EEC) topic. EEC is actually a feature of Google Universal Analytics and it doesn't mean a full e-commerce tracking. Google Ads or Google Analytics 4 doesn't have enhanced e-commerce tracking; they have their own terms for the same reports. As for the question, you can not do a complete enhanced e-commerce setup without a Shopify Plus plan because you will miss the checkout steps. For a complete e-commerce tracking using Google Tag Manager; we would strongly recommend using: [Analyzify: GTM & GA4 App for Shopify](https://apps.shopify.com/analyzify). 

### How to track Shopify checkout steps using GTM? 
Well, this is only possible if you are on a Shopify Plus plan as explained in-depth above. You won't be able to add a code to the checkout steps on Shopify without having to access to checkout.liquid file. 

### How to track Add To Cart event with Google Tag Manager? 
It is relatively a complex setup as "Add to Cart" scripts differ from store to store. We recommend using an app to have an accurate solution on this. As Analyzify, we provide a custom development support to make ["Add to Cart" tracking work properly on Shopify stores](https://docs.analyzify.app/add-to-cart-event-not-working-as-expected). 

### Does Shopify have GTM data layers? 
Shopify doesn't have the data layers by default. However, there are open-source solutions like [Analyzify Shopify data layers](https://github.com/analyzify/shopify-google-tag-manager) that you can use. 

### What about Shopify Google Tag Manager apps? 
The apps will provide you a more in-depth setup, data layers, pre-built Google Tag Manager container, and support. We would strongly recommend using [one of the Shopify GTM apps](https://analyzify.app/google-tag-manager-shopify/apps) especially if you are spending good amount of marketing dollars. Your reporting and tracking will get better and it should help with your ROI. 



### Final Words on Usage of GTM on Shopify
We only walked through the installation and setup process in this tutorial. GTM is powerful and beneficial. You should research more and learn better to take advantage of it in the best possible way.