Identity methods
The SDK provides methods to manage customer identity for analytics and cross-session tracking. See Identity Tracking for a conceptual overview.identify(userId, traits?)
Associates the current visitor with a known user identity. Call this after a user logs in.
Your system’s unique user identifier.
Optional metadata about the user (name, email, etc.).
- Persists
userIdandtraitsin the browser - Updates the in-memory identity state
- Sends identity update to all currently open widgets
- Sends the identity data to the Selektable server in the background
reset()
Clears the stored identity and generates new anonymous IDs. Call this when a user logs out.
- Generates a new visitor ID, session ID, and anonymous ID
- Removes stored user ID and traits
- Updates all open widgets with the new identity
getIdentity()
Returns the current identity object.
setVisitorId(visitorId)
Manually overrides the auto-generated visitor ID.
Custom visitor ID to use.
- Overwrites the visitor ID
- If no user is identified, also updates the anonymous ID
- Updates the in-memory identity state