Hi there,
We’re using PostHog on our production site, which is built with Next.js. For checkout, users are redirected to Shopify’s hosted checkout at a URL that looks like https://shop.app/checkout/XXX.
To track conversions, we fire an event using the PostHog JS SDK inside a custom Shopify pixel, following the approach described here Shopify - Docs - PostHog.
That guide doesn’t mention cross-domain tracking, but this tutorial does:
“Tracking users across different domains, like posthog.com and hogflix.com, requires some extra work. You need to pass users’ distinct_id and session_id between PostHog initializations to ensure they are connected…”
It also clarifies that PostHog handles tracking automatically across subdomains but not across entirely different domains.
When inspecting the events fired by the pixel inside Posthog, it appears the domain for the URLs associated with the events are using a subdomain we have assigned to our storefront, rather than shop.app. My guess is that Shopify is somehow ‘masking’ the true domain for consistency or reporting purposes, but that the pixel executes in a sandboxed environment hosted at shop.app – meaning it wouldn’t have access to cookies set by PostHog on our main domain.
If that is correct, the implication is that the PostHog SDK in the checkout pixel cannot access the session cookie set by Posthog on our primary domain, and therefore we’d need to pass the session_id manually to maintain continuity across domains – as outlined in the cross-domain tracking guide.
Shopify’s documentation seems to support this (https://help.shopify.com/en/manual/promoting-marketing/pixels/overview):
“There are some limitations on what information can be accessed, because pixels run in a secure sandbox environment… These limitations might not be compatible with some third-party pixels.”
I just wanted to confirm whether this interpretation is accurate?
Thank you in advance.