How to Add Google Tag Manager to Shopify (2026)

Last updated
Expert reviewed
5 min read
Jacques Blom
Jacques Blom
CTO at Fudge.

Key takeaways

  • GTM requires two snippets: one in the <head> and one immediately after the opening <body> tag in theme.liquid.
  • Shopify’s code editor makes this a straightforward edit — no developer needed.
  • Standard Shopify plans restrict GTM access to the checkout page — use Shopify’s Customer Events API for checkout tracking.
  • Always test with GTM Preview mode before going live.

Google Tag Manager lets you add and manage marketing tags (GA4, Meta Pixel, conversion tracking, heatmaps) without touching your theme code every time. Once GTM is installed, everything else is managed from the GTM dashboard.

Here’s how to install it on Shopify.

Why you can trust us

Jacques has 15+ years of Shopify development experience, including setting up analytics and tracking for hundreds of stores. We built Fudge — an AI storefront editor with a 5.0 rating on the Shopify App Store.


Where to add Google Tag Manager in Shopify

GTM requires two code snippets in your theme.liquid file:

  1. In the <head> tag — the main GTM script
  2. Immediately after the opening <body> tag — the no-script fallback

Both placements matter. The <head> snippet loads GTM as early as possible. The <body> snippet is a fallback for browsers with JavaScript disabled.


Step-by-step: Adding GTM to your Shopify theme

Step 1 — Get your GTM container snippets

Log in to tagmanager.google.com. Select your container. Click Admin → Install Google Tag Manager.

You’ll see two code snippets. Keep this tab open.

Step 2 — Open the Shopify code editor

Go to Online Store → Themes → Actions → Edit code.

In the left sidebar under Layout, click theme.liquid.

Step 3 — Add the <head> snippet

Find the closing </head> tag. Paste the first GTM snippet directly above it.

<!-- Google Tag Manager -->
<script>...</script>
<!-- End Google Tag Manager -->
</head>

Step 4 — Add the <body> snippet

Find the opening <body> tag (it may have attributes like class="..." — that’s fine). Paste the second snippet immediately after it.

<body>
<!-- Google Tag Manager (noscript) -->
<noscript>...</noscript>
<!-- End Google Tag Manager (noscript) -->

Step 5 — Save and verify

Click Save in the code editor. Then go back to GTM and use Preview mode to check that your container is firing on your store pages.


How to add tags to your Shopify store after GTM is installed

Once GTM is installed, you manage everything from the GTM dashboard — no more editing theme code.

To add GA4: GTM → Tags → New → Google Analytics: GA4 Configuration → enter your Measurement ID → set trigger to All Pages.

To add Meta Pixel: GTM → Tags → New → Custom HTML → paste your pixel code → trigger on All Pages.

Publish your container after adding tags — changes in GTM are not live until you click Submit.


Can GTM track Shopify checkout pages?

On standard Shopify plans, no. Shopify restricts third-party script access to the checkout page for security reasons.

For checkout and purchase event tracking, Shopify recommends using the Customer Events API (available in Online Store → Settings → Customer events). This is the supported way to fire conversion events from the thank-you / order status page.

On Shopify Plus, you can customise checkout.liquid directly, which gives you full GTM access on the checkout page.

Want tracking set up without touching code? Try Fudge.
Try Fudge for Free

Common GTM and Shopify mistakes

Installing GTM twice. If you previously added a Google tag via the Shopify integration (under Settings → Customer events), you may already have a GTM-like tag firing. Check before adding GTM manually.

Wrong snippet order. The <head> snippet must come before </head>. The <body> snippet must come directly after <body>. If either is placed incorrectly, GTM may load slowly or not at all.

Forgetting to publish. GTM changes only go live when you click Submit. Draft changes do nothing on your live store.

Not testing first. Always use GTM Preview mode before publishing. It shows exactly which tags are firing on which pages.


How to connect Google Tag Manager to Shopify’s built-in analytics

Shopify has its own basic analytics. GTM sits on top of it and sends data to GA4 (or other platforms). They don’t conflict.

For the most complete picture, connect GA4 via GTM and also link your Google Ads account to GA4 directly. This gives you conversion tracking across both channels without duplicate tags.


Do I need a developer to add Google Tag Manager to Shopify?

No. Installing GTM on Shopify requires editing one file — theme.liquid — and pasting two code snippets in the right places. The process takes around 10 minutes and doesn’t require any knowledge of Liquid or JavaScript. If you’d prefer not to touch the code, you can describe the change to Fudge and it will make the edit as a draft for your review.


How do I verify Google Tag Manager is working on Shopify?

After saving your theme.liquid changes, use GTM’s Preview mode to confirm the container is firing. Enter your store URL and a debug panel will show which tags are active on each page. For purchase tracking, complete a test order and confirm the conversion tag fires on the order confirmation page. Also see our guide on setting up conversion tracking in Shopify.

Jacques's signature
Make Shopify changes without touching code.

You might also be interested in

How to Track Scroll Events in Shopify (2026)
Add scroll depth tracking to your Shopify store — fire GA4 events at 25%, 50%, 75%, and 100% scroll depth using GTM or custom JavaScript in theme.liquid.
How to Track Click Events in Shopify (2026)
Track button clicks and link clicks in Shopify using Google Tag Manager click triggers, GA4 Enhanced Measurement, or custom JavaScript with data
How to Fix Duplicate Pixel Events in Shopify (2026)
Fix duplicate purchase events in Shopify — find and remove conflicting pixel installations, check the Customer Events API vs manual code, and use GTM