How to Add Tracking Scripts to Shopify (2026)

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

Key takeaways

  • The recommended method for checkout and purchase tracking is Settings → Customer events (Shopify’s pixel manager).
  • For app-specific scripts, use App Embeds in the Theme Editor rather than manually adding code to theme.liquid.
  • Third-party script access to the checkout page is limited on Basic and Shopify plans — Shopify Plus unlocks more.
  • Adding scripts directly to theme.liquid is the most powerful but least safe method — duplicate your theme first.

Tracking scripts power your ads, analytics, and remarketing. Getting them installed correctly in Shopify is more nuanced than pasting a snippet into a header. Shopify has multiple methods, each suited to different use cases.

How do I add a tracking code to Shopify?

There are three main methods:

  1. Customer Events (pixel manager) — for purchase and checkout event tracking
  2. App Embeds — for app-specific scripts
  3. theme.liquid — for global scripts across all pages (except checkout on lower plans)

Shopify’s Customer Events system (formerly Shopify Pixels) is the proper place for purchase and checkout event tracking. It works across the entire checkout — including the order status page — on all Shopify plans.

Step 1 - Go to Settings → Customer events

Step 2 - Click Add custom pixel (for custom code) or browse the list of pre-built integrations (Google, Meta, TikTok, Klaviyo, etc.)

Step 3 - For a pre-built integration: click the integration, connect your account, and enable it. Shopify handles the rest.

Step 4 - For a custom pixel: paste your tracking code into the JavaScript editor. Your code runs in a sandboxed environment and has access to Shopify’s standard events (page_viewed, product_viewed, checkout_completed, etc.)

Why this is the recommended approach: Customer Events runs in a privacy-compliant sandbox, respects customer consent settings, and has full access to checkout events that theme.liquid scripts cannot reach on standard plans.


Method 2 — App Embeds in the Theme Editor

When you install a Shopify app that includes a JavaScript snippet (like a review widget, live chat, or loyalty program), the correct way to enable it is through App Embeds:

Step 1 - Go to Online Store → Themes → Customize

Step 2 - Click the puzzle piece icon in the left sidebar (App Embeds)

Step 3 - Toggle on the app you want to enable

This method keeps app scripts organized, makes it easy to enable/disable without touching code, and avoids leftover script tags if you later uninstall the app.


Method 3 — theme.liquid (for global scripts)

For scripts that need to run on every page of your store (excluding checkout on lower plans), you can add them directly to theme.liquid.

Step 1 - Online Store → Themes → Actions → Edit code

Step 2 - Open theme.liquid

Step 3 - Add scripts in the <head> section (for scripts that must load early) or just before the closing </body> tag (for non-critical scripts)

Always duplicate your theme first. A syntax error in theme.liquid breaks your entire storefront.

Use defer or async on script tags where possible to avoid blocking page rendering:

<script src="https://example.com/script.js" defer></script>

How do I add a script in Shopify to the checkout page?

Checkout page script access depends on your Shopify plan:

Basic, Shopify, Advanced plans: Scripts cannot be added directly to checkout pages via theme.liquid. Use Customer Events instead — it has access to all checkout events.

Shopify Plus: Access to checkout.liquid for the checkout page. Also has Shopify Functions and Checkout Extensibility for more advanced customization.

All plans: The order status (thank you) page can receive additional scripts via Settings → Checkout → Order status page (scroll to the bottom of the Checkout settings page to find the “Additional scripts” field).


Common tracking script mistakes

Installing a pixel twice. If you use Shopify’s native Meta integration AND paste the Meta Pixel code manually into theme.liquid, purchase events will fire twice. Use one method only.

Missing consent management. If you operate in the EU or California, you need a consent banner and your tracking scripts should only fire for consenting users. The Customer Events system handles this properly when configured correctly.

Scripts blocking page load. Render-blocking scripts in <head> delay your page from displaying. Add async or defer attributes to any non-critical tracking scripts.

Add tracking and conversion elements to your Shopify store.
Try Fudge for Free

Using Google Tag Manager as a single source of truth

Rather than adding multiple tracking scripts directly to Shopify, many stores use Google Tag Manager (GTM) as a container. You add the GTM snippet once to theme.liquid, then manage all other tracking scripts inside GTM.

Benefits: no code changes needed when adding or modifying tracking, easier to add/remove scripts for non-developers, built-in debugging tools.

See our full guide: How to add Google Tag Manager to Shopify.

Jacques's signature
Add conversion elements to your Shopify store by describing them.

You might also be interested in

How to Add a Custom Conversion Element in Shopify (2026)
Add countdown timers, urgency bars, trust badges, and sticky CTAs to Shopify — and track their impact on conversions
How to Add Google Tag Manager to Shopify (2026)
InstallGoogleTagManageronyourShopifystoreinminutes.Coversexactscriptplacement,checkouttrackinglimitations,andcommonmistakes
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.