PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
20.73k stars 1.24k forks source link

Cannot track users across multiple domains #9684

Closed mteterel closed 2 days ago

mteterel commented 2 years ago

Bug description

We have multiple domains for our project which are linked to the same PostHog instance and project. However we cannot, at the moment, track users across different domains, PostHog always create a different user ID.

How to reproduce

  1. Go on domain1.some.site
  2. Click on a button that brings you to domain2.some.site
  3. In PostHog, 2 different users are now created

Environment

neilkakkar commented 2 years ago

Hey @mteterel , if you have a way to identify users (for example, if both domains have a login page), you can use posthog.identify() to connect these users.

mteterel commented 2 years ago

One of our domains does not have a login page, but it is using the same instance and PostHog project than another domain that do. It does not appear to reconciliate data.

What I expect from PostHog was that :

mariusandra commented 2 years ago

Hey there, what you're describing requires the use of third party cookies to track a user across the web. Such cookies are becoming more and more penalized by browsers, and if we would enable this, it would hurt our ability to simply track visits within one domain.

If your domains are all related (both are subdomains), you may use cross-domain cookies to pass around a unique ID that your users will be identified with. If you're using completely separate domains, you'll need to pass the ID dynamically in a link from one domain to another, the same way that Google Analytics does.

peteygao commented 2 years ago

@mariusandra Okay, that makes sense about 3rd party cookies. Does that mean if we use posthog.identify(UUID) across two different subdomains (where we generate the UUID and store it in cross-domain a cookie), internally Posthog will merge them as the same user even if the identify call is from two different subdomain?

Context: We're running into the same issue as @mteterel and was expecting the user merging across domains to be automatic, but I can understand why it isn't after your explanation. Thanks.

mariusandra commented 2 years ago

@peteygao that's right. If you're tracking events from different domains onto the same project, as is common practice, then using the same distinct ID will link the session to the same user, no matter the domain.

posthog-bot commented 2 weeks ago

This issue hasn't seen activity in two years! If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in two weeks.

posthog-bot commented 2 days ago

This issue was closed due to lack of activity. Feel free to reopen if it's still relevant.