1. Why user mapping matters
Adding user information to events helps you:- Group multiple flows (for example login retries and recovery) under the same user
- Analyze authentication behavior in a per-user view
- Connect anonymous pre-login events with known users as soon as identity is available
2. User reference model
Corbado Observe supports these user reference fields:userId: Your stable internal user IDidentifier: Deprecated. A flow-level user-facing reference that existing integrations can keep sending; new code captures identifiers on the provide-identifier step insteadcrossEnvironmentTransactionID: Optional correlation ID for cross-device or email-link flows
userId for user enrichment. Capture submitted emails, phone numbers and usernames separately on the provide-identifier step so each submission remains searchable, including typos, changes and failures.
User reference fields are limited to userId, identifier and crossEnvironmentTransactionID.
3. Send user references from the SDK
CallsetUser() on the tracker as soon as the identity is known, while the flow is open. The SDK records it as a flow_enriched event on that flow, and the classifier attaches it to the flow and to every attempt inside it. Call it before flowFinished(). One call per identity observation is enough; the latest reference per flow wins.
Choose the point at which your authentication system supplies the reference:
- When the host confirms the user: Send the
userIdwith the login result, before finishing the flow. - When an enrollment flow starts: The user is already logged in, so the reference is known at
flowStarted(). - When the host resolves an account before authentication: An early user reference can identify the account being targeted. Its presence alone does not establish who made the attempt or prove ownership of a submitted identifier.
userId or identifier inside flowFinished(), flowAutoFinished(), conversion() or the userReference step option still works and is deprecated. Use setUser() in new code.
For SDK installation and setup, see Integrate custom events.
- NPM
- CDN
4. Best practices
- Prefer your immutable internal user ID for
userId(or a hash of it if you prefer not to expose your user IDs) - Capture identifiers per submission for debugging and support workflows
- Send the same user reference consistently across all relevant auth events
- Do not use tags for identity mapping; use tags for segmentation