Shopify Google Tag Manager (GTM) Setup | Centralize GA4 and Ad Tags with dataLayer Best Practices

shopify
11mm編集部

A guide to setting up Google Tag Manager (GTM) on Shopify. Covers when to use GTM over native integration, centralized management of GA4 and ad tags, how the dataLayer works with Liquid templates, checkout page limitations, and our service's GTM approach.

Introduction: What Is Google Tag Manager (GTM)?

Google Tag Manager (GTM) is a tag management system that lets you add, update, and remove tracking and marketing tags on your website without modifying code directly. GA4 tracking, Google Ads conversion tags, Facebook Pixel, and other third-party tags can all be managed from a single GTM interface.

Installing GTM on Shopify means you can change or add tracking configurations without touching your theme code each time.

Benefits of Using GTM on Shopify

  • Centralized tag management: GA4, Google Ads, Meta Ads, and other tags managed in one place
  • No code changes required for updates: Add or change tags without modifying the theme
  • Flexible event tracking: Configure custom events such as specific button clicks, scroll depth, and form submissions
  • Easy testing and debugging: Preview mode lets you verify behavior before publishing

Examples of Tags Managed via GTM

TagPurpose
GA4 (Google Analytics)Site-wide user behavior and conversion tracking
Google Ads conversion tagTracking purchases and inquiries from paid ads
Google Ads remarketing tagRetargeting site visitors with ads
Facebook PixelMeta Ads conversion and audience tracking
Other third-party toolsChat widgets, surveys, heatmaps, etc.

Native Shopify Integration vs. GTM: When to Use Each

Shopify's native Google channel app provides basic GA4 tracking without code. GTM is the better choice in these situations:

  • Managing multiple ad tags simultaneously (Google Ads, Meta Ads, etc.)
  • Configuring custom GA4 events for specific interactions (button clicks, product page behavior)
  • Full-order builds with custom themes where automatic tags may not fire correctly
  • Anticipating frequent tag additions or changes in the future

For theme template builds tracking GA4 only, the native Shopify integration is often sufficient.

The dataLayer and How It Works on Shopify

What Is the dataLayer?

The dataLayer is a JavaScript object that passes information from your web page to GTM. It communicates data like which product was viewed, what was added to cart, and what the purchase total was — information that GTM then forwards to GA4 tags and ad tags. Using the dataLayer enables you to send detailed product attributes (category, brand, variant) to GA4's Ecommerce reports that standard tracking cannot capture.

Liquid Templates and the dataLayer

Shopify themes run on the Liquid template engine. To pass product data into the dataLayer, you embed Liquid variables — such as {{ product.title }} and {{ product.price | money_without_currency }} — inside JavaScript objects in your theme files. The dataLayer is initialized in the theme's head or section files, and GTM reads that data and forwards it to your configured tags.

Checkout Page Limitations and Custom Pixels

Shopify's checkout pages (cart, payment, order confirmation) are managed by Shopify itself, and Liquid editing is restricted on the Basic plan. This limits how much detail you can push into GTM from the checkout flow. Since 2023, Shopify has recommended its Custom Pixels feature for checkout-area tracking. Combining GTM with the Custom Pixels API is now the standard approach for measuring purchase completion events in detail. Shopify Plus expands what can be customized on the checkout page.

How Our Service Handles GTM

We choose between Shopify's native integration and GTM based on build type and the tags required.

  • Theme template and theme customization builds: Native integration is the default for GA4 and Search Console only. GTM is available when additional tags such as Google Ads are needed.
  • Full-order development: GTM is the standard due to the flexibility and extensibility it provides for tag management.

In all cases, GA4 will be tracking correctly at the time of launch. For pricing by build type, see Shopify Build Cost Guide: 3 Types Compared.

GTM's Relationship with GA4 and Search Console

GTM is the delivery mechanism — the measurement itself is handled by GA4, and search performance is managed through Search Console.

Summary

  • GTM is a tag management system for centralizing GA4, ad tags, and other tracking
  • GTM is the right choice for multiple tags, custom events, and full-order builds
  • The dataLayer connects Liquid templates to GTM, but checkout pages have plan-based restrictions
  • Our service selects between native integration and GTM based on build type
  • GTM handles tag delivery; GA4 and Search Console handle measurement and SEO management

FAQ

Yes, GTM works on all Shopify plans — Basic, Shopify, Advanced, and Plus. You install it by inserting the GTM snippet into the head element of your Shopify theme.