Quick Summary
Google Tag Manager Shopify setup comes down to three jobs: create a GTM container, load it in the right place, and pass Shopify’s customer events into the data layer so your tags can read them. On a current Shopify store, checkout tracking runs through Custom Pixels (Settings > Customer events), not through old theme or checkout code. Choose one source for every event, test with a real order, and check for duplicates before you trust any report.
Quick answers:
- What is GTM? A free tag management tool that lets you add and update tracking tags from one dashboard instead of editing theme code each time.
- Where does the code go? Google’s snippet goes in the head of a page, with a noscript snippet right after the opening body tag. Shopify’s documented route for checkout events is a Custom Pixel.
- What breaks tracking most often? Duplicate purchase events, mismatched data layer names, and a pixel that was saved but never connected.
Why Tracking Breaks in Google Tag Manager and Shopify
Tracking breaks quietly. A theme edit, a new app, or a checkout change can stop purchase events from reaching Google Analytics 4 or your ad platforms, and nothing in your Shopify admin warns you. The first sign is usually a conversion report that no longer matches your orders.
Google Tag Manager (GTM) is meant to make this safer by putting your tags in one place. But if you search for google tag manager shopify guides, you will find older tutorials that tell you to paste code into checkout files, newer ones that rely on Custom Pixels, and some that tell you to do both. Following the wrong one is how stores end up with missing purchases or double-counted revenue.
This guide gives you a safer order of operations: what to prepare, how to install GTM on Shopify in a way that matches how checkout works today, how to connect data layer events, and how to test the result before anyone makes budget decisions from it.
Google Tag Manager Shopify Setup: What to Prepare First
A clean GTM tracking setup starts before you touch any code. Ten minutes of planning prevents most of the problems covered later in this article.
What Google Tag Manager Does for a Shopify Store
GTM is a container that holds your tags, the rules that fire them, and the variables they read. Google describes a tag as a segment of code from an analytics, marketing or support vendor, and Tag Manager lets you configure and publish those tags from its interface instead of adding each one to your site by hand.
GTM does not collect data on its own, and it is not an analytics tool. Google Analytics 4 reports on your traffic and sales. GTM is the delivery system that decides which tags load, when they fire and what information they carry. If your GTM container is empty, nothing is being tracked through it.
Prerequisites Checklist
Before you install GTM on Shopify, gather the following:
- Admin access to your Shopify store, with permission to edit themes and manage Customer events.
- A Google account that can create or edit a Tag Manager account.
- A list of every tracking tool already running on your store: Google Analytics 4, Google Ads, Meta Pixel, TikTok Pixel, Microsoft Clarity and any app-injected scripts.
- Your GA4 measurement ID and Google Ads conversion details, if you plan to send data there.
- A duplicate (backup) of your live theme, in case you edit theme files.
Decide Which Tool Owns Each Shopify Event in Google Tag Manager
This is the step most guides skip. If Shopify’s built-in sales channel, an app and your GTM container all report the same purchase, your platforms will count it more than once. Write down one owner per event before you start.
| Event | Example owner | What to do with the others |
|---|---|---|
| Page view | GTM (via GA4 tag) | Disable duplicate page view tags in apps |
| Add to cart | GTM or one app | Keep one source only |
| Begin checkout | GTM through Custom Pixel | Remove old hardcoded calls |
| Purchase | One source only | Turn off the native or app version that repeats it |
You can change the owners later, but you should never leave two owners active for the same conversion.

Install GTM Shopify Step by Step
Now for the practical part. These steps follow Google’s container instructions and Shopify’s Custom Pixel documentation. Shopify’s interface changes over time, so check the current screens against the official pages linked below.
Step 1: Create Your Google Tag Manager Container for Shopify
- Open Google Tag Manager and sign in with your Google account.
- On the Accounts tab, create an account (usually one per company), then create a container.
- Give the container a clear name, such as your store domain, and choose Web as the container type.
- Accept the terms. GTM shows an installation dialog with your container ID, which starts with “GTM-“.
Google explains this flow in its Tag Manager installation guide. Keep your GTM container ID handy, since later steps and any app will ask for it.

Step 2: Choose How the Container Will Load
Shopify stores generally load a GTM container in one of two ways, and picking the right one is what protects your tracking.
Option A: Load GTM through a Custom Pixel (the Shopify-documented route). Shopify’s help center has a dedicated tutorial for creating a Google Tag Manager custom pixel. You copy the head snippet from GTM, remove the HTML script tags, paste the remaining code into a new Custom Pixel, and subscribe to customer events that get pushed into the data layer. This is the best starting point because it covers checkout, where theme code does not reach.
Option B: Theme snippet plus Custom Pixel. Some practitioners also add the GTM snippet to the theme so the container can see on-page behavior such as form submissions or clicks, and use the Custom Pixel for checkout events. This can work, but the sandbox and the storefront are separate environments. If the same container loads in both places with unscoped tags, you can fire the same tag twice. If you choose this route, scope your triggers carefully and test for duplicates.
For most stores, start with Option A. Add the theme snippet only when you have a specific need that Custom Pixel events cannot meet.
Step 3: Add the Container Snippet (If You Use the Theme)
If you go with Option B, Google’s rule is simple: place the first snippet as high in the head as possible, and place the noscript snippet immediately after the opening body tag. In Shopify, that means editing your theme’s main layout file under Online Store > Themes > Edit code.
Before saving, search the theme for older GTM code. A second snippet is one of the quickest ways to double-count everything.
Google Tag Manager Shopify Checkout Tracking With Custom Pixels
Checkout is where store revenue is recorded, and it is also where most failed tracking projects go wrong. Shopify’s checkout runs in a controlled environment, and Shopify has been moving merchants toward checkout extensibility as older checkout code is retired. Custom Pixels are how third-party tracking fits into that model.
How a Shopify Custom Pixel Works With Google Tag Manager
In your Shopify admin, go to Settings > Customer events and choose Add custom pixel. Shopify’s custom pixel runs in a sandbox, and the help center notes that tag managers loaded there have the same restrictions as any other pixel. Inside the pixel, you subscribe to Shopify’s standard customer events, such as page views, product views, add to cart and checkout completed, and then push each one into the GTM data layer.
![]()
A simplified pattern looks like this:
// 1. Paste your GTM head snippet here (without the <script> tags)
// 2. Then subscribe to the events you want GTM to receive
analytics.subscribe("checkout_completed", (event) => {
window.dataLayer.push({
event: "checkout_completed",
orderId: event.data.checkout.order.id,
currency: event.data.checkout.currencyCode
});
});
Treat this as an illustration only. Shopify’s help center publishes a maintained example, and field names can change, so compare your code with the current version before going live.
Configure Google Tag Manager to Accept Shopify Events
Shopify’s tutorial is clear that sending events is only half the job. Your GTM container must be ready to receive them, and that takes three parts:
- A trigger of the Custom Event type, where the event name matches the event key in your pixel. For the example above, that is
checkout_completed. - Data layer variables for each value you want to read, such as
orderIdandcurrency. Each value needs its own variable. - A tag that uses the trigger and variables, such as a GA4 purchase event or a Google Ads conversion tag.
Shopify also notes that at least one tag and one trigger must be set up in GTM for data to flow. If you are mapping to GA4, remember that GA4 expects specific parameter names for ecommerce events, so your tag may need a small translation step between Shopify’s field names and GA4’s.
Respect Consent Settings
Consent changes whether your pixel runs at all. Shopify states that in markets configured to require consent, such as the European Economic Area and the United Kingdom, web pixels run only after visitors have given the permissions set on the pixel. By default, new pixels require Marketing and Analytics permissions.
This is the correct behavior, but it explains many “missing data” reports. If your purchase count in GA4 is lower than your Shopify order count, consent can be one reason. Review your customer privacy settings and the pixel’s permission settings together, and do not remove consent requirements just to make numbers match.
How to Test GTM Shopify Tracking Before You Trust It
Even a clean GTM tracking setup can fail quietly. Testing is where you prove that your google tag manager shopify setup works, and it should happen before you change ad budgets or report conversions to a client.
Debugging Tools for Google Tag Manager on Shopify
Shopify recommends the Shopify Pixel Helper to confirm that the events you expect are reaching the sandbox without errors. The Google Tag Assistant extension can still show which Google tags load on a page, but Shopify’s documentation warns that Tag Assistant’s troubleshoot feature is not compatible with custom pixels and may not detect tags loaded inside them.
Several practitioner guides and merchants in Shopify’s community forum also report that GTM Preview mode behaves differently inside the sandbox, and that container changes may need to be published before you can see them working. Plan to test with published changes and real events, not just preview sessions.
For a broader look at how to confirm that a pixel is actually firing, our guide on how to verify, test and troubleshoot a pixel on Shopify walks through the same mindset with Meta’s tools.
A Simple Testing Routine
- Open your store in a fresh browser window and browse a product page, then add an item to the cart.
- Check the Shopify Pixel Helper for the events you subscribed to.
- Place a real test order using a low-cost product or a payment method you can refund.
- Open GA4’s DebugView and your ad platform’s diagnostics. Confirm the purchase arrived once, with the right order ID, value and currency.
- Compare the order in Shopify with the event details. The numbers should match.
If any step fails, fix it before moving on. A single clean purchase event is better evidence than a dozen page view screenshots.
Common Google Tag Manager Shopify Mistakes That Break Tracking
Most GTM Shopify problems follow predictable patterns. Use this section as a troubleshooting list.
Duplicate Shopify Purchase Events in Google Tag Manager
If Shopify’s native Google connection and your GTM tag both send a purchase for the same order, GA4 can record two conversions and inflate revenue. Practitioner guides recommend picking one source and disabling the other. If GTM is your tracking layer, turn off the native connection that sends the same event.
Also search your theme files and installed apps for hardcoded gtag purchase calls. These sometimes survive long after a developer thinks the cleanup is finished.
Mismatched Google Tag Manager Data Layer Names on Shopify
If your Custom Pixel pushes transactionId but your GTM variable expects transaction_id, the variable returns undefined and the tag may fire with blank values, often without a visible error. Keep a short naming sheet and make sure the pixel, the GTM variables and the tags all use the same spelling.
A Pixel That Is Saved but Not Connected
In Shopify, saving a custom pixel is not the same as connecting it. If your checkout event never arrives, confirm the pixel status is connected, then check the pixel’s error log in the Customer events area for syntax problems.
Old Checkout Code Left Behind
If you previously had dataLayer.push calls in older checkout code, Shopify’s guidance is to replace them with analytics.publish() calls so custom events flow through the new system. Leaving old code in place can create duplicates or leave dead code that confuses later audits.
Too Many Overlapping Tools
Every extra script adds weight and another place for errors. If your store already runs several tracking apps, audit them before adding another layer. Our guide to speeding up your Shopify store explains how third-party scripts can slow pages down, which is a good reason to keep your GTM container lean.
When an App Is Easier Than Manual Setup
Manual setup gives you control, but it also needs someone who can read JavaScript and re-test after changes. Whether you install GTM Shopify manually or use an app, the principles above stay the same, and some merchants prefer an app for the installation step.
Using an App for Google Tag Manager Shopify Installation
Infinite Commerce’s Google Ads Tracking & GTM app is built for merchants who want to connect a container without writing code. According to the app page, the flow is to install it from the Shopify App Store, paste your Google Ads conversion ID or GTM container ID, and let the app handle the event setup. The page lists Page View, Add to Cart, Begin Checkout and Purchase events on the Standard plan, with GA4 and Bing integrations and server-side setup on higher plans, and a 7-day trial is advertised.
An app does not remove the need to plan. You still need to decide who owns each event, avoid running the same purchase tracking in two places, and test with a real order. What it can do is reduce the amount of custom code you maintain yourself. Check the current plan details on the app listing before you decide, since features and pricing can change.
Pre-Launch Checklist for Your GTM Shopify Setup

Run through this list before you consider your Shopify custom pixel GTM setup finished:
- GTM container created as a Web container, with the container ID saved.
- No second GTM snippet or old Google tag code left in the theme.
- Custom Pixel is connected, not just saved.
- GTM triggers match pixel event names exactly.
- Data layer variables match the field names in the pixel.
- One owner per conversion event, with duplicates disabled.
- A real test order verified in GA4 and your ad platforms.
Conclusion
A reliable google tag manager shopify setup is less about clever code and more about order and discipline. Create the container, choose how it loads, send Shopify’s customer events into the data layer, give every conversion a single owner, and test with a real order before you trust the numbers. Most of the pain comes from skipping one of those steps, not from GTM itself.
If you would rather not build and maintain the installation yourself, the Infinite Commerce team builds Shopify apps for tracking and feeds, and you can start with the Google Ads Tracking & GTM app listed above. For more practical Shopify tracking guides, browse the Infinite Commerce blog.
Ready to connect your GTM container the simple way? Try the Infinite Google Ads Tracking & GTM app from the Shopify App Store and test it against a real order today.
FAQs
Google Tag Manager is a free tool for managing tracking tags. In Shopify, you connect a GTM container to your store so you can add, change and remove tags such as GA4 or ad conversion pixels from the GTM dashboard, rather than editing theme code for every change.
Create a Web container in Google Tag Manager, copy the installation code, and add it through a Shopify Custom Pixel under Settings > Customer events. Shopify’s official tutorial explains how to remove the script tags, subscribe to customer events and push them to the data layer. Some stores also add the snippet to the theme for on-page tracking. You can read the official steps in Shopify’s Google Tag Manager custom pixel guide.
Common causes include a custom pixel that is saved but not connected, a trigger event name that does not match the pixel, a syntax error in the pixel code, or consent settings that stop the pixel from running for some visitors. Check the pixel’s error log first, then confirm names and permissions.
You can, but only if you avoid sending the same event from both. If both the native connection and GTM report a purchase, platforms can count the order twice. Choose one source for each conversion and disable the other.
GTM itself is a small loader, but every tag you add through it can add work for the browser. Keep the container lean, remove tags you no longer use, and review third-party scripts regularly.