Skip to main content

Shopify

Shopify stores can install PureStats in the theme layout so the tracker is loaded on storefront pages.

Add the tracker to theme.liquid

  1. Open your Shopify admin.
  2. Go to Online Store -> Themes.
  3. Choose your active theme and open Edit code.
  4. Open layout/theme.liquid.
  5. Paste the PureStats script before the closing </head> tag.
  6. Save the theme and open your storefront to send the first pageview.
<script defer src="https://purestats.io/pf.js" data-domain="example.com"></script>

Replace example.com with the domain configured in PureStats.

Theme updates

Theme updates can overwrite custom template edits. If your theme supports custom code injection, prefer that option. Otherwise, note the change in your deployment checklist so the tracker is re-added after theme updates.

Checkout and additional domains

Shopify checkout can run on a different hostname depending on your plan and configuration. If you track across multiple hostnames, add every allowed hostname in Site Settings -> Domains before enabling cross-domain stitching.

Avoid tracking admin and preview pages

The script should be installed only in the public storefront theme. If a theme app or custom setup injects it into preview, account or internal pages, add path exclusions in PureStats.

Common exclusions:

  • /admin
  • /admin/*
  • /account
  • /account/*
  • /checkout/*

Verify installation

After saving the theme, open a public product, collection or homepage URL in a normal browser window. Then click Verify Installation in PureStats. If the script loads but no hit is received, check consent apps, theme optimization apps and Content Security Policy settings.