Skip to content

Commit

Permalink
Add docs for posthog.createPersonProfile (#10522)
Browse files Browse the repository at this point in the history
* Add docs for posthog.createPersonProfile

* Add docs for cross-domain tracking

* Update contents/tutorials/cross-domain-tracking.md
  • Loading branch information
robbie-c authored Jan 31, 2025
1 parent 7a846a3 commit d900d38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contents/docs/data/anonymous-vs-identified-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ We derive the following values from the persistence store:

Note that the above initial parameters will only work across subdomains if you're using `persistence: "localStorage+cookie"` (default) or `persistence: "cookie"`.

For cross-domain traffic, or when tracking users between web and mobile, cookie-based data wouldn't be available on the new site, so it's advised to call one of:
* `posthog.identify()` if you have a persistent user ID available, or
* `posthog.createPersonProfile()` if you don't have a persistent user ID. Make sure that you are bootstrapping the PostHog SDK on the new second or mobile app with the anonymous distinct ID from the first site.

Any other initial [person properties](/docs/product-analytics/person-properties#default-person-properties), including initial [GeoIP properties](/docs/product-analytics/person-properties#geoip-properties) will be set from the values in the event at the time that the person profile was created i.e. when the events became identified.
</details>

Expand Down
2 changes: 2 additions & 0 deletions contents/tutorials/cross-domain-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ First-party cookies ensure you get the most data possible, as third-party cookie

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. This not only ensures tracking is accurate and consistent, but [session replays](/docs/session-replay/installation#how-to-record-sessions-across-different-domains) and [feature flag evaluations](/docs/feature-flags/bootstrapping) work across domains too.

If you are using anonymous events, call `posthog.identify()` or `posthog.createPersonProfile()` before leaving the first site, to make sure that initial person properties like `$initial_referrer` are set correctly.

### Getting IDs on the first website

To do this, first, we need to get the `distinct_id` and `session_id` from the first website. To do this, we can call `posthog.get_distinct_id()` and `posthog.get_session_id()` and pass them in the URL hash to the second domain.
Expand Down

0 comments on commit d900d38

Please sign in to comment.