posthog.com
posthog.com copied to clipboard
Docs - Tracking anonymous users across frontend and backend
Strapline
If you have the concept of a logged in user, collating events between frontend and backend is trivial, just use posthog.identify(unique_id). But if you don't have that concept, it's much harder. See this thread for an example of how one user hackily solved this.
Figuring this out was one of my biggest frustrations using a competitive product a couple of years ago.
Why should we do it?
It'd be good for us to give an 'official' way of doing this. There are two main options:
- Use posthog-js as normal in the frontend, then grab the cookie in the backend as per this thread. Downside is the server would only have access to the distinct id after the first page load. Simplest, and could make this even simpler by integrating it in the client libs?
- Create a random unique ID in the backend, send that to the frontend. Most reliable but fiddly.
Outline
Bullet point outline of structure / questions / topics to be covered
@timgl That link is now dead. Is there documentation anywhere as to how to grab the cookie from the backend so you can identify "people" that have already been created on the front-end?
Still a missing piece in the docs.