Cross-domain tracking with Shopify

Shopify needs one extra, one-line snippet in your theme to make cross-domain tracking work. Your existing Custom Pixel is unchanged and keeps sending events.

Set this up with AI

Copy this prompt into ChatGPT, Claude or whichever AI you use. It carries this whole guide, the pages it depends on, and a link to every video, so it can walk you through it one step at a time.

Open as text

If your funnel uses Shopify together with a second, separate domain, for example an advertorial or landing page domain that sends visitors on to your Shopify store, Shopify needs one small extra step beyond the Custom Pixel install. This page covers only that extra step; read Cross-domain tracking first for what the feature does and how to turn it on.

Every Shopify store in a cross-domain funnel should have this snippet. It is one line, it covers both directions, and it does not depend on anything else being up to date.

Why Shopify is the one special case

A Shopify Custom Pixel runs inside a locked sandbox. It has no document.cookie access and no DOM access, so it cannot add anything to a link a visitor is about to click, and it cannot write a cookie on the store's own domain. That is a restriction Shopify puts on every Custom Pixel, not something TrueMetriks chose. It means the pixel can report events, but it can never be the thing that hands a visitor off between two domains.

So Shopify needs a second, small snippet, pasted into your theme, that does only the handoff. Your existing Custom Pixel does not change at all, and keeps sending pageview, checkout, and order events exactly as it does today.

Get the snippet

  1. Make sure Cross-domain tracking is turned on for the site, in Settings > Websites > your site > Tracking, with your other domain listed and saved.
  2. Staying on the Tracking tab, pick the Shopify card.
  3. Below the Custom Pixel code you will see a section titled "Click here if you're doing cross-domain tracking with Shopify". It only appears once cross-domain tracking is switched on for the site; if you do not see it, go back and turn the toggle on first.
  4. Open it and click Copy on the one-line snippet inside. It looks like this:
<script async src="https://t.yourdomain.com/t/s-shopify-link.js"></script>

Your own snippet will have your site's actual tracking host in place of t.yourdomain.com.

Install it in your theme

  1. In Shopify Admin, go to Online Store > Themes.
  2. On your live theme, click Edit code. A draft theme is the single most common reason this ends up doing nothing.
  3. Open theme.liquid.
  4. Paste the script tag on its own line, just before the closing </head> tag.
  5. Click Save.

That is the whole install. It runs on every storefront page the theme renders. Shopify's own checkout pages cannot be edited and do not need this snippet; your Custom Pixel's events already pick up the visitor id the theme snippet sets once the visitor is on your storefront.

Turn password protection off

A password-protected Shopify store breaks cross-domain tracking, snippet or no snippet. Shopify redirects the visitor to /password and drops the query string on the way, which takes the handoff with it.

Check it in Shopify Admin under Online Store > Preferences. This catches people out on development stores in particular, where password protection is locked on until the store is on a paid plan. If you are testing a cross-domain funnel against a development store, that is the first thing to rule out.

What it does, and does not, do

  • It adopts an incoming handoff from another listed domain, so the visitor keeps the same identity when they land on your Shopify store.
  • It tags outgoing links to your other listed domain or domains, so a visitor leaving your Shopify store for another domain in your funnel carries the handoff with them.
  • It fires no events of its own. Your Custom Pixel is the only thing sending events; this snippet only sets up the identity that the pixel then reports.

If your store is only ever the destination

There is one case where the theme snippet is not strictly required, and it is worth knowing about even though the advice does not change.

The current Custom Pixel reports the page a visitor came from. So when someone lands on another domain first and then clicks through into your Shopify store, the store can pick the handoff up from that alone, with no theme snippet. Your store as the destination works either way.

The other direction does not, and never will. When a visitor starts on your Shopify store and clicks out to another domain in your funnel, something has to tag that outgoing link, and only unsandboxed code can do that. That is the theme snippet's whole job.

Two reasons to install it anyway, which is why this is a note and not a recommendation.

  1. It only applies once you have re-copied your pixel. The Custom Pixel is code you pasted into Shopify, not a hosted script we can update for you. If you pasted yours before this behaviour shipped, your store is still running the old version and does not report the referring page at all. Re-copy your Custom Pixel from the Tracking tab's Shopify card and paste it over the old one in Shopify Admin to pick it up.
  2. It is one line and it covers both directions, so it keeps working the day you add a second step that leaves the store, and it does not depend on when anybody last re-pasted anything.

Check it worked

There is no status badge for this, on purpose. Run the two-minute Sessions test from the main guide: Test it yourself. One session containing pages from both your Shopify store and your other domain means it is working.

If it still shows as two sessions, in order: confirm the script tag is saved in theme.liquid on the live theme, confirm password protection is off, then work through Cross-domain tracking troubleshooting.

Frequently asked questions

Why does Shopify need a second snippet at all?

A Shopify Custom Pixel runs inside a locked sandbox: it has no access to document.cookie or the DOM, so it cannot add anything to an outgoing link or write a cookie on the store domain. That is a restriction Shopify puts on Custom Pixels, not something TrueMetriks chose. The theme snippet runs unsandboxed, so it can do the handoff the pixel cannot.

Does this replace my Custom Pixel?

No. Your existing Custom Pixel is unchanged and keeps sending pageview, checkout, and order events exactly as before. The theme snippet does only the cross-domain handoff, nothing else, and fires no events of its own.

Where exactly do I find the snippet?

In the dashboard, open Settings > Websites > your site > Tracking, pick the Shopify card, and open the section titled "Click here if you're doing cross-domain tracking with Shopify". That section only appears once cross-domain tracking is turned on for the site, in the Cross-domain tracking section on the same tab.

Do I need to touch Shopify's checkout pages?

No. Shopify's own checkout pages cannot be edited and do not need this snippet. Your Custom Pixel's checkout events already carry what they need once the theme snippet has set the visitor id on the storefront.

My Shopify store is only where visitors arrive, never where they leave from. Do I still need it?

Strictly, no. The current Custom Pixel reports the page a visitor came from, so a store that is only ever the destination can pick up the handoff without the theme snippet. Install it anyway, for two reasons. First, that only applies once you have re-copied your Custom Pixel from the Tracking tab and pasted it over the old one, because the pixel is code you pasted rather than a hosted script we can update for you. Second, it is one line and it covers both directions, so it keeps working the day your funnel gains a step that leaves the store. A visitor starting on your Shopify store and clicking out always needs it, because only unsandboxed code can tag an outgoing link.

Do I need to re-copy my Custom Pixel?

If you pasted it before the pixel started reporting the referring page, yes, and it is worth doing regardless. Open Settings > Websites > your site > Tracking, pick the Shopify card, copy the Custom Pixel code, and paste it over the existing one in Shopify Admin under Settings > Customer events. It is the same pixel, just the current version.

Cross-domain tracking works everywhere except my Shopify store. Why?

Two usual causes. The snippet is in a draft theme rather than the live one, or the store has password protection turned on, which makes Shopify redirect to /password and drop the handoff. Both are covered on this page.

Do I need this if I am not using cross-domain tracking?

No. This section will not even appear in your dashboard until Cross-domain tracking is turned on for the site. If your funnel lives entirely on Shopify, skip this page.

Need help with this?

Reach us instantly on WhatsApp, or send us a message and we will get back to you. On workdays we usually respond in less than 24 hours.

or send us a message