Cross Domain Tracking

Heads up — this article is mostly relevant if you're tracking sales. If you're only tracking leads (email opt-ins), cross-domain handling generally doesn't apply to you. Leads are captured on the same page the visitor landed on after clicking your tracking link, so there's no domain boundary to cross. You can skip this article. The cross-domain situations described below come into play only when a sale completes on a different domain than where the click originally landed — which only happens during sales / checkout flows.

Most online funnels live entirely on your own domain — viewer clicks a tracking link, lands on your opt-in, completes checkout, and sees your thank-you page, all on yourbrand.com or subdomains of it (like cart.yourbrand.com or checkout.yourbrand.com). Video Stats handles all of these scenarios automatically with no extra setup — even across subdomains.

True cross-domain tracking only becomes a concern in two specific situations:

  • You're using Video Stats' built-in opt-in pages (hosted on videostats.ai) and your sale fires on your own site afterward
  • Your checkout or thank-you page is on a third-party shopping cart's domain — one that isn't yours and isn't a subdomain of yours (e.g., checkout.othersite.com)

If neither of those applies to you, you don't need to do anything special — attribution will work automatically. If one or both do apply, this article explains how Video Stats keeps attribution intact across the domain boundary.

Why Subdomains of Your Own Domain Aren't a Problem

If your funnel uses your root domain plus subdomains — for example, opt-in on yourbrand.com and checkout on cart.yourbrand.com — Video Stats handles this transparently.

When a visitor clicks a tracking link and arrives on any page that has your tracking code installed, Video Stats sets a first-party cookie at the root domain level (.yourbrand.com) so every subdomain can read it. As long as the Video Stats tracking code is installed on every domain or subdomain in your funnel, the visitor's attribution follows them automatically. No extra setup, no special configuration.

The cross-domain mechanisms described below are only relevant when the visitor crosses to a domain that isn't yours and isn't a subdomain of yours.

How Attribution Normally Works

When a viewer clicks one of your Video Stats tracking links, the link service appends a unique tracking ID to the URL and redirects to your destination. The Video Stats tracking script on your destination then:

  1. Reads the tracking ID from the URL
  2. Stores it as a cookie on your domain (good for 30 days)
  3. Reads that cookie when the sale snippet fires (sale)

The catch: a cookie set on yourbrand.com is not automatically readable on checkout.othersite.com (a totally different domain). That's a browser security rule, not a Video Stats limitation. So if the visitor crosses to an unrelated domain between the click and the sale, that second domain has no cookie to read — and the sale would come in unattributed unless we do something about it.

How Video Stats Handles True Cross-Domain Tracking

For the two scenarios that genuinely span unrelated domains — using built-in opt-in pages with a sale on your own site, or selling through a third-party cart — Video Stats uses two complementary mechanisms. You don't have to choose between them; they both run automatically.

1. URL Parameter Forwarding (For Built-In Opt-In Pages)

If you're using Video Stats' built-in opt-in pages (hosted at videostats.ai/p/yourchannel/...) and redirecting visitors to a thank-you page on your own domain after opt-in, Video Stats automatically appends the tracking ID to that redirect URL.

When the visitor arrives on your thank-you page, the tracking script reads the ID from the URL (instead of from a cookie) and writes a fresh cookie on your domain. From there, it works exactly like a same-domain funnel.

This means: as long as your thank-you page has the Video Stats tracking code on it, attribution will follow the visitor across domains automatically.

Tip: If you'd like to keep the entire flow on your own brand, the White-Label Marketing Pages feature lets you serve Video Stats opt-in pages from your own subdomain (e.g., pages.yourbrand.com) instead of videostats.ai. With that enabled, the opt-in and thank-you pages both live on your domain and attribution works through the same automatic subdomain cookie sharing — no cross-domain handling needed at all.

2. Email-Based Fallback (For Tricky Carts)

Some third-party shopping carts strip query parameters from URLs as the customer moves through checkout — so even though Video Stats tries to forward the tracking ID, it might get lost on the way to the final thank-you page.

To handle this, Video Stats also stores a private mapping of email addresses to clicks at opt-in time. If a sale comes in without a tracking ID but with the customer's email, Video Stats automatically looks up the most recent click for that email (within 30 days) and attributes the sale to that video.

For this fallback to work, pass the customer's email in your sale tracking snippet:

ytTracking.trackSale({
    amount: 9999,
    currency: 'USD',
    orderId: 'ORDER-123',
    email: '[email protected]'  // Critical for cross-domain fallback
});

If you don't pass email, and the cart strips the URL parameter, the sale will come in unattributed.

Tip: Always pass the customer's email in trackSale calls. It's the most reliable safety net for cross-domain funnels.

Setup by Funnel Type

Setup A: Your Own Domain (Including Subdomains of It)

Example: Opt-in on yourbrand.com, checkout on cart.yourbrand.com — or the entire funnel on yourbrand.com

What to do: Just install the Video Stats tracking code on every domain or subdomain in your funnel. The script handles everything automatically.

✅ No extra setup required.

Setup B: Built-In Opt-In Page → Your Domain

Example: Opt-in on videostats.ai/p/yourchannel/free-training, redirect to yourbrand.com/thanks

What to do:

  1. Install the Video Stats tracking code on yourbrand.com/thanks (and ideally sitewide on your domain)
  2. In the opt-in page settings, set the redirect URL to your thank-you page (Video Stats will automatically append the tracking ID to that redirect)
  3. If a sale fires on the thank-you page, pass email in your trackSale call as a safety net

✅ Works automatically once the tracking code is installed on your destination domain.

Setup C: Your Domain → Third-Party Shopping Cart → Your Thank-You Page

Example: Opt-in on yourbrand.com, checkout on cart.providerxyz.com, thank-you redirect back to yourbrand.com/thanks

What to do:

  1. Install the Video Stats tracking code on yourbrand.com (including the thank-you page)
  2. If your shopping cart preserves URL query parameters, the tracking ID will pass through automatically — most modern carts handle this fine
  3. As a safety net, always pass the customer's email in your sale snippet — Video Stats can fall back to the email lookup if the URL parameter gets stripped along the way

✅ Reliable as long as email is included in trackSale.

Setup D: Your Domain → Third-Party Cart Where the Thank-You Page Is on the Cart's Domain

Example: Opt-in on yourbrand.com, sale completes on secure-cart.othersite.com and you can't redirect back to your domain

What to do:

If you can install custom JavaScript on the third-party thank-you page, paste the same Video Stats tracking code + sale snippet there, and pass email in trackSale. Video Stats will use the email-based fallback to find the original click.

If you can't add code to the third-party thank-you page, that platform is essentially a black box — Video Stats can't see the sale. In this case, you'd need either a custom integration with the cart provider's webhook, or a workflow that sends customers to a thank-you page you control after the purchase. Contact support if you're in this situation; we can help you map a path forward.

Best Practices

  • Always include the customer's email in trackSale calls. It's the single most effective safeguard against cross-domain edge cases.
  • Install the tracking code on every page in your funnel, not just the entry and exit. Some carts and funnel builders re-render pages in ways that benefit from the script being present throughout.
  • Test the full flow yourself. Click a tracking link in incognito, go through your funnel end-to-end with a real $1 test purchase, and confirm the sale shows up in your dashboard attributed to the right video.
  • Watch for cache or CDN settings that strip query strings. Some aggressive caching configurations remove tracking parameters from URLs before the tracking script can read them.

Limitations

There are a few cases where cross-domain attribution can't work, no matter how the setup is configured:

  • The visitor never clicks a tracking link. If they typed your URL directly, came from organic search, or arrived via social media, there's no click to attribute the sale to. That's expected behavior, not a bug.
  • The visitor clears their cookies between click and sale. Without the cookie or the URL parameter, there's nothing to match against — unless their email matches a recent opt-in (the fallback path).
  • The thank-you page is on a third-party domain you can't add code to, and your cart doesn't pass the email or order ID back. Without any way to fire a sale event from a page you control, attribution isn't possible.

Troubleshooting

Most sales are attributed, but some are coming through unattributed

This is normal. Some visitors clear cookies, use incognito mode, or block third-party scripts. The goal is to maximize the percentage that does attribute, not to hit 100%. If your attribution rate suddenly drops though, see the next item.

Attribution worked yesterday but isn't working today

  • Check if your cart provider pushed an update that changed how URL parameters are handled
  • Check if you (or your developer) recently changed redirect URLs in the funnel
  • Check your site cache / CDN settings for anything that might strip query strings
  • Run a fresh end-to-end test in incognito to isolate where the chain breaks

My attribution numbers don't match my actual sales

Video Stats only attributes sales that originated from a tracking link click. The total in your Stripe / Shopify / cart will always be higher than your video-attributed total — that's the rest of your traffic (direct, organic, paid ads, etc.). The point of Video Stats isn't to count all sales, but to tell you which YouTube videos are driving revenue.

My checkout strips URL parameters and customers' emails aren't being passed to trackSale

This is the worst-case cross-domain scenario. Options:

  1. Update your sale snippet to pull the email from your cart's order data and pass it explicitly to trackSale
  2. Switch to a cart that preserves URL parameters
  3. Add a Video Stats-controlled thank-you page after the cart's thank-you page (a "redirect to your real thank-you" pattern) where you can fire trackSale with the order data