Skip to content
whovisited.

Shopify · Analytics setup

Add WhoVisited to a Shopify theme and verify storefront tracking

Install the browser tracker once in Shopify's shared theme layout, check consent and duplicate snippets, and understand why this does not cover checkout or custom pixels.

Choose the surface you actually need to measure

A Shopify store owner often wants one simple answer first: are people reaching the product, collection, and content pages that I publish? For those online-store pages, a browser tracker can be added once through the theme's shared layout. That is a narrower task than measuring checkout, post-purchase, customer-account, or every Shopify surface. Decide which surface matters before choosing an installation method.

Shopify describes `layout/theme.liquid` as the default layout for non-checkout storefront pages. It is the base used by many templates, so one snippet there can cover those pages when they use that layout. Checkout uses a different integration surface. The standard WhoVisited browser snippet is not a Shopify web-pixel extension and does not turn a checkout completion into a recorded purchase.

Add one snippet to the active theme layout

  1. In Shopify Admin, open Online Store → Themes and duplicate the published theme first. Make the change in the duplicate, preview it, then publish it through your normal theme workflow.
  2. In the theme code editor, open `layout/theme.liquid`. This is the Liquid layout file, not a product template or a section that repeats for each product.
  3. Copy the exact script URL and site ID from your WhoVisited installation settings. Add the tag once before the closing `</body>` tag, keeping Shopify's required `{{ content_for_layout }}` and `{{ content_for_header }}` objects untouched.
liquid
<!-- Keep this tag once in layout/theme.liquid. -->
<script async src="https://whovisited.net/tracker.js"
  data-site-id="YOUR_SITE_ID"></script>

</body>

Replace `YOUR_SITE_ID` with the site ID from your account and use the script host shown in the current installation snippet. The site ID is sent to the browser by design; it is not a database password or an API secret. Do not copy secrets, order details, or customer identifiers into theme code or analytics properties.

Before saving, search the theme files for `tracker.js` and check whether a tag manager, another app, or a previous theme edit already loads WhoVisited. Keep a single installation owner. A duplicated snippet can cause duplicate page views or make it difficult to tell which configuration produced a visit.

Do not confuse theme HTML with Shopify's ScriptTag API

Shopify has announced that ScriptTag records created by apps will stop being injected into storefront pages on March 1, 2027. That API is different from a merchant adding an ordinary HTML `<script>` directly to `theme.liquid`. Shopify's migration guidance lists theme app embeds for storefront app code and web pixels for analytics-only app integrations; its documentation also notes that theme code can remain after an app is removed, but theme edits require care during theme changes.

The hand-edited theme method above is a practical storefront installation for the current WhoVisited browser snippet. It can be lost when you replace or update the theme, and it applies only to pages rendered through that layout. Keep a note of the change and repeat the verification whenever the published theme changes. If you are building a Shopify app for distribution, follow Shopify's extension guidance instead of creating app-managed ScriptTag records.

A custom pixel is not a paste-any-script box

Shopify custom pixels run in a sandbox. Shopify documents that a custom pixel cannot access the top frame and that traditional pixels relying on browser APIs such as `window.document` do not work normally in that environment. The current WhoVisited tracker reads the page location and document title, uses local and session storage for visitor and session IDs, and sends events with browser `fetch()`. Pasting the standard tracker tag into Shopify's custom-pixel editor is therefore not a verified integration and can report the sandbox URL or miss required browser state.

A Shopify web-pixel app extension can subscribe to Shopify customer events and access Shopify's pixel APIs, but it must be built specifically for that environment and honor its consent model. WhoVisited's standard tracker script is not such an extension. Until a dedicated, tested pixel integration exists, use the standard tag for the online-store theme only and do not claim checkout or post-purchase measurement from it.

Verify the published theme in a real browser

  1. Open the published storefront—not only the theme editor preview—in a fresh browser profile. Use a test site or a clearly identifiable QA visit if you do not want test activity in normal reports.
  2. Open DevTools Network and reload a product or collection page. Confirm `tracker.js` loads once, followed by the bootstrap request and an event request to the configured WhoVisited host.
  3. Check the event response and then look for the visit under the intended WhoVisited website. A script request or a successful-looking browser console is not proof that the event was accepted.
  4. Repeat on a home, product, collection, and content page that uses the shared theme layout. Then test any alternate storefront hostname or separate layout that matters to your reporting.
  5. If consent is required, confirm no collection happens before approval and that a page view appears after a valid grant. Keep the tracker disabled when the visitor has not granted the required consent.

This setup helps answer questions about browser sessions on the online store. JavaScript blockers, denied consent, privacy signals, network failures, theme changes, and origin settings can prevent or limit collection. Use Shopify order records as the source of truth for purchases; WhoVisited's theme tracker is not a payment ledger or a substitute for a Shopify web-pixel implementation.

References and further reading

  1. Shopify: Theme layouts and theme.liquid
  2. Shopify Help Center: Edit theme code
  3. Shopify: Storefront ScriptTag deprecation
  4. Shopify: Web pixel sandbox environments
  5. WhoVisited: Consent changes and browser privacy signals
  6. WhoVisited: Content Security Policy for the tracker