Skip to main content
Replaces the current user id (the auto-generated anonymous UUID, or a previous id) with your application’s stable id. Call it when you know who the user is: after login, signup, or session restore.

Signature

userId
string
required
Your application’s unique id for this user. Use an opaque identifier (not an email or other personal data), and use the same id across sessions and devices; claims, subscription events, and measurement join on it.
attributes
UserAttributes
Optional attributes set in the same call, equivalent to a following setUserAttributes().
Returns void. Fire-and-forget: the id is applied and persisted locally right away, and the backend link (previous id → new id) is sent asynchronously.

Example

Behavior

  • The new id is persisted in localStorage and used for all subsequent SDK activity.
  • Calling with the same id again is a no-op, so it is safe to call on every page load.
  • Identify as early as you reliably can, ideally before the first offer presentation, so activity binds to the stable id rather than the anonymous one.
  • When switching to a different user (account switch), call reset() first, then identify() the new user.

getCurrentUserId()

Returns the id from identify(), the auto-generated anonymous UUID otherwise, or null before configure().

getAppAccountId()

The persistent account identity that this user’s claims, exposures, and subscription events are bound to, the same value your server forwards as app_account_id on subscription webhooks. Currently resolves to the same value as getCurrentUserId().