Prompt
How do I set up identity resolution for anonymous and known users?
Latest observation
Identity resolution for anonymous + known users is usually about linking a person’s pre-signup behavior to their later authenticated profile, so you can unify events, profiles, and attribution.
Here’s the standard setup pattern:
1) Define a stable anonymous identifier
When a visitor first arrives, assign a persistent anonymous ID, such as:
- a cookie-based
anonymous_id - a device ID
- a browser/localStorage ID
Use this ID consistently for all pre-login events.
2) Track anonymous events with that ID
For every event before login/signup, send:
anonymous_id- event name
- timestamp
- properties
Example:
page_viewproduct_viewadd_to_cart
3) Capture the known user identity at signup/login
When the user authenticates, you’ll usually have a stable known ID such as:
user_idcustomer_id- CRM ID
- account ID
Send an identify/login event with both:
- the known ID
- the prior anonymous ID
This is the key linking step.
4) Merge the identities
Your identity system should create a mapping like:
anonymous_id -> user_id
After that, future events can be attached to the known profile, and past anonymous events can be retroactively associated if your platform supports it.
5) Maintain identity graphs carefully
If users can log in on multiple devices/browsers, your system should support linking multiple anonymous IDs to one user ID.
Rules to avoid confusion:
- one known
user_idcan map to many anonymous IDs - don’t merge two different known users unless you’re certain
- treat identity updates as deterministic and auditable
6) Handle logout and device switching
On logout:
- stop using the known ID for new events
- continue assigning a fresh anonymous ID if appropriate
On another device:
- a new anonymous ID will be created
- once the user logs in, link it to the same known user ID
7) Respect consent and privacy
Make sure this setup aligns with:
- cookie consent requirements
- privacy policy disclosures
- data retention rules
- opt-out/delete requests
Avoid storing personally identifiable information in the anonymous ID itself.
Typical event flow
Before login
{
"event": "product_view",
"anonymous_id": "anon_123",
"properties": {
"product_id": "sku_456"
}
}
On login/signup
{
"event": "identify",
"anonymous_id": "anon_123",
"user_id": "user_789",
"traits": {
"email": "person@example.com"
}
}
After login
{
"event": "purchase",
"user_id": "user_789",
"properties": {
"order_id": "ord_111"
}
}
If you’re using a CDP or analytics tool
Most tools provide built-in identity resolution with concepts like:
- anonymous ID
- user ID
- alias/merge
- identify
In that case, the main job is:
- use the tool’s recommended identity methods
- ensure
anonymous_idis captured before login - call
identifyat signup/login - verify event stitching works in reports
If you tell me which platform you’re using (Segment, RudderStack, Amplitude, Mixpanel, GA4, Snowplow, etc.), I can give you the exact implementation steps and code.