Skip to main content
identify connects your external_id (whatever you call users in your own database) to a Spotzee user record and updates that record’s traits. Until you call identify, the SDK records activity against an anonymous ID that the browser variants mint and persist for you.

Identify a known user

The browser variants reuse the anonymous ID they minted on first use, so you don’t pass anonymousId yourself. The Node Client requires you to pass both IDs explicitly because it can’t safely persist them between calls.

How traits flow

Anything you put in traits lands as a top-level field on the user record. The set of traits Spotzee accepts is defined by your project’s data schema. Read Define custom user attributes for how to add, remove, or rename traits. A few traits map to specific behaviour:
  • email and phone: top-level fields the email and SMS channels read from. Pass them through identify arguments rather than nesting them in traits so the SDK puts them in the right place.
  • timezone and locale: drive personalisation and send-time logic. Pass them through identify arguments. The browser SDK does not infer them; if you want browser locale, read navigator.language and pass it in.

Anonymous to known: automatic alias

The first identify call after an anonymous session aliases the anonymous ID to your external_id. All prior anonymous activity now belongs to the known user. The browser SDK caches the external_id after this call, so subsequent track and identify calls carry both IDs automatically. For server contexts where you already know the anonymous ID separately (for example, a user signed up server-side with a session you tracked earlier), call alias directly:

When to call identify

  • On sign-up. First call after the user creates an account.
  • On sign-in. So a user switching devices or browsers gets joined back to their record.
  • When traits change. Updating profile data, plan, lifetime value, billing state. Identify is upsert: pass only the traits that changed.
Avoid calling identify on every page load with the same data. The platform deduplicates server-side, but the network call is wasted.

Reset on sign-out

The SDK caches externalId for the lifetime of the page. To clear it (for example, on sign-out), drop the page reference to the client and create a new one:
A fresh BrowserClient mints a new anonymous ID. Subsequent activity is anonymous until the next identify.

Next steps

Track events

Trigger journeys and feed segments with custom events.

Define custom user attributes

Decide which traits Spotzee accepts.