This is your step-by-step, detailed guide for setting up Google Tag Manager on your Shopify store - prepared by true experts who love to share!

Google Tag Manager (GTM) works great on Shopify - including non-Shopify plans. However, setting up Google Tag Manager on Shopify isn’t a quick process but there are a number of ways to set it up. We will walk you through the possible options with step-by-step tutorials.

Chapter 1

Setup Method 1: Manually Install GTM on Shopify

Shopify GTM Setup Chapter 1

In this method, we will guide you step by step to manually install Google Tag Manager (GTM) container in your Shopify store. We will also carry out debugging at the end of the section to ensure the GTM container is correctly placed.

We have made a dedicated YouTube tutorial video that you can watch at the end of this section. Click here if you want to do the GTM set up on Shopify using our video tutorial.

How to set up Google Tag Manager without Shopify Plus [no-app]

  1. Step 1: Create a Google Tag Manager (GTM) account and get your code
  2. Step 2: Find and edit Shopify theme files
  3. Step 3: Install GTM code into Shopify theme
  4. Step 4: Add Google Tag Manager to Shopify checkout
  5. Step 5: Find and edit checkout > additional scripts
  6. Step 6: Validate setup using GTM
  7. Step 7: Visit your Shopify store on GTM preview mode
  8. Step 8: Run tests and finalize validation
  9. Step 9: Validate your GA4 setup using GTM's preview mode
  10. Step 11: Install Shopify purchase data layer (open-source)
  11. Step 12: Set up GTM tags & triggers for Shopify

Let's not get into the details and start setting up GTM on your Shopify store. Don't forget to check the bottom section of the article where we will use the data layers, GTM tags and triggers to enhance and complete your setup. That will allow you to set up conversion tracking through Google Tag Manager as well.

Get your Google Tag Manager (GTM) Container Code

Step 1: Get your GTM Container Code

Let’s get your GTM container code. Go to your Google Tag Manager account. Click on your GTM ID on the top-right corner of the screen (labeled as #1 in the screenshot). Copy the first part of the code.

If you don’t have an account yet, you can follow this tutorial to create a GTM account, and then come back here.

Place the GTM Container in your Shopify Theme

Step 2: Edit theme files

Go to your Shopify Store Admin > Online Store > Themes

As we will have to edit your theme files, it is a good idea to start by duplicating your theme so you have a backup. Duplicate your current theme so if something goes wrong, you will have the option to revert back to it again.

After duplication, Click Actions > Edit Code.

GTM code for theme mannual setup

Step 3: GTM code into Shopify theme

Go to your Shopify Store Admin > Online Store > Themes

As we will have to edit your theme files, it is a good idea to start by duplicating your theme so you have a backup. Duplicate your current theme so if something goes wrong, you will have the option to revert back to it again.

After duplication, Click Actions > Edit Code.

Note: If you are using a Page Builder App that has created new liquid files in your theme; you will need to paste the GTM container code in those pages separately. Otherwise, GTM will not be visible on those pages. Make sure to visit all of your pages and see if the GTM container is placed correctly. We will conduct a debug at the end of the tutorial.

Place the GTM Container in your Shopify Theme

Step 4: GTM code into thank-you page

Unfortunately, Shopify doesn’t allow us to add code to the Checkout page unless you have the Shopify Plus plan. So the GTM will not work on your checkout and cart pages. That being said, it is not that big a deal. What matters most is the “purchase completed” and we will now add the code there.

Go to Shopify Admin > Settings > Checkout

Order Processing

Step 5: GTM - Additional Checkout Scripts

Find the section called Order Processing. Just paste the same GTM container code here and save it. If you have any other codes in this section, you don’t need to modify them; just add the GTM container code at the top.

This will allow the GTM container to work on the thank-you page. In this way, you can track sales and conversions.

If you are on a Shopify Plus plan, you don’t need to do this. Just add the GTM snippet into the checkout.liquid file.

GTM Preview

Step 6: Validate setup using GTM

Now it’s time to verify if our GTM tag is installed correctly in our store. Go back to your Google Tag Manager account and click Preview. If your GTM container is empty, it will ask you to publish the preview because you just created this account. Publish, approve and move on.

GTM Preview

Step 7: GTM Preview Mode

Type in your store’s URL and continue. This will open your store and you’ll see “Debugger Connected” in the bottom-right corner; if everything is installed correctly.

Tag Assistant Process

Step 8: Finalize validation

Make sure that you visit a few different pages, and hard refresh them if you are not seeing any changes right away.

You can also run a test order to make sure that our GTM container is also triggered on the Purchase Completed page. Remember the GTM Debugger will not be working in checkout steps but it should come back on the thank-you page.

We have now completed setting up Google Tag Manager on your Shopify store. However, adding only the GTM container won’t do anything by itself. You will also need to add tags, triggers, variables through Google Tag Manager.

You will find more details on how you can use GTM on Shopify in our related section. ⬇️

Chapter 2

Setup Method 2: Using a Shopify GTM App

Shopify GTM Setup Chapter 2

Data has immense importance for e-commerce stores and that’s why every click, user action, and engagement matter. You want to make sure that you can track all the most important events with correct data and share that with third parties such as Google Analytics, Ads, Facebook Pixel, and many others.

You can consider using a Shopify GTM app to fully integrate your Shopify store with Google Tag Manager. The GTM apps in the Shopify app store can help you with:

  • Installing GTM container on your store (similar to what we have done above),
  • Injecting data layers on your store so that you can pass all relevant data using GTM to other parties,
  • Providing you with a ready-to-go GTM container file so that you don’t have to add the tags, triggers, variables one by one,
  • Connect your store with Google Ads, Analytics, Facebook Pixel and many others,
  • Give you guidance and support along the way.

Analyzify - the Shopify Google Tag Manager app doesn’t only make GTM work on your store; but also adds complex, advanced dataLayers to your Shopify store that allow you to collect more data and pass it using Google Tag Manager.

Each Shopify store is its own world with different apps and themes. Most stores have customized their theme in a unique way and that’s one of the reasons why the standard implementation might not work as expected. That’s why it is very important to receive support from the app team to make sure that tracking works accurately and smoothly.

It’s no surprise that we recommend Analyzify which is a versatile solution for Shopify Data Analytics. We have a world-class data and development team that has created an amazing solution and we also provide extraordinary support and free custom setup.

Adding GTM to your Shopify store doesn’t do much by itself. You should rely on tags, variables, custom events, and a wide range of GTM features to make the most out of it.

Google Tag Manager is an incredibly powerful tool, especially for Shopify stores where every bit of data is essential. Here is a quick look at why GTM is so important for Shopify businesses.

Above all else, GTM allows you to access, organize, and process all of your data in the most efficient way possible.

Instead of trying to send the data to different sources, (such as Analytics, Ads, and Facebook Pixel) GTM stores the data within dataLayers, allowing you to process and share it with any tool you want, all within minutes.

Chapter 3

GTM Tags/Triggers for Shopify

Shopify GTM Setup Chapter 3

We will now try to cover how GTM can be useful for Shopify merchants and what tags/triggers/variables they can use to enhance your data analytics setup.

You can use Google Tag Manager to set up

  • Google Analytics 4 including e-commerce tracking,
  • Google Ads conversions (micro-macro),
  • Google Ads dynamic remarketing,
  • Bing Tag including conversion tracking,
  • Custom event tracking,
  • and many others.

To achieve this, you need to set up a data layer on your store and then create relevant tags, triggers, and variables on Google Tag Manager.

You will find an example roadmap below to set up Google Analytics 4 e-commerce tracking using Google Tag Manager for your Shopify store. In this way, you will understand better how it works and you will have a working example.

Install Shopify data layer

Step 1: Install Shopify data layer

We have prepared a public - open-source data layer for Shopify merchants. You can visit our Shopify data layer page and install it on your store.

Create variables on GTM

Step 2: Create variables on GTM

You will also find instructions on how to create variables on Google Tag Manager. Create the purchase-related variables such as order ID, revenue, payment type, and others.

You will need to use these variables on your tags.

Note: In the video, there are fewer variables that we provided in step 1. Feel free to add the related variables if you feel comfortable playing around.

We will keep adding more tutorials and step-by-step guides to help the Shopify community!

Chapter 4

FAQ on Google Tag Manager Setup

Shopify GTM Setup FAQ

You can view your store's source and search for a line starting with "GTM-". The container's code snippet should be visible if you have GTM already installed in your store.

If you do have it installed, just mark the related section during your onboarding, and Analyzify will take care of the rest.

If you don't have it installed, worry not, as Analyzify will do it for you.

Shopify stores use different coding methods and apps to set the add-to-cart function, and unfortunately, there is no easy way to add this event on GTM.

So, we would highly recommend using an app like Analyzify to achieve this.

You can set up GTM on Shopify's checkout pages using the "checkout.liquid" file. However, this is only possible and available for Shopify Plus merchants at the moment.

The good news is, Shopify announced that this will soon be available for all plans!

There are some work arounds - but we DO NOT recommend them. They don't work properly, and they can even break your existing tracking in the process.

Firstly, Enhanced E-commerce (EE) is a Universal Analytics feature, and you do not need to use Google Tag Manager to set up Enhanced E-commerce on Shopify.

You can follow our Universal Analytics Complete Setup guide to achieve a full Enhanced E-commerce tracking.

Because of the "checkout.liquid" file limitations, setting EE through GTM is only possible for Shopify Plus clients. If you are one and still wish to set it up, you can use Analyzify to achieve this.

Definitely yes. GTM is useable for non-Shopify Plus stores as well. You can add the GTM container to theme.liquid file and order processing additional scripts.

The only limitation that regular Shopify stores have is NOT being allowed to edit the checkout process due to checkout.liquid file limitations.

Purchase tracking and other user behavior metrics/reports are so crucial and you will still have a majority of the events/reports.

Google Tag Manager and all other tracking codes will still WORK on every page + order processed (thank you page) but the checkout steps won’t be included.