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
- 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.
- 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.
- 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.
<!-- 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.
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.
Match the storefront domain and consent behavior
The browser sends events from the actual storefront origin. In WhoVisited, make sure the store's live HTTPS hostname is allowed for the selected website. If customers can browse through both a primary domain and a separate custom storefront domain, test each origin you intend to measure; do not assume that an admin or `myshopify.com` URL is the customer-facing storefront.
If your store requires prior analytics consent, add `data-consent="required"` to the tag and connect your consent manager so it calls `window.whovisited.consent(true)` only after permission is granted and the tracker is available. Call `consent(false)` when permission is withdrawn. Do not use a theme-preview visit to bypass the store's consent choice. For a detailed explanation of the browser signals and consent methods, use the [WhoVisited consent integration guide](https://whovisited.net/blog/handle-consent-changes-and-privacy-signals).
A restrictive Content Security Policy can also block the tracker script or its requests. If the browser console names a `script-src` or `connect-src` violation, update only the relevant policy for the required analytics origin. The [tracker CSP guide](https://whovisited.net/blog/verify-csp-for-whovisited-tracker) explains which requests to inspect.
Verify the published theme in a real browser
- 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.
- 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.
- 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.
- 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.
- 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.