Skip to main content

Anonymous users

You don’t have to provide a user id. On configure(), the SDK auto-generates a UUID and persists it in localStorage (falling back to sessionStorage, then memory), so the same visitor keeps the same id across reloads until they clear browser data or you call reset().

Identify users

When you know who the user is (after login, signup, or session restore), attach your own stable id, optionally with attributes in the same call:
Call identify() as early as you reliably can, and use the same id across sessions and devices. Claims, subscription events, and measurement all join on this id (the SDK’s app account id, also readable via Encore.getAppAccountId()), so a stable id keeps a returning user’s history in one place. localStorage is per-origin and per-browser; only your own id survives a device switch. See identify() for the full contract.

User attributes

Strongly recommended. Country and language already shape which offers a user is shown. Once you know who the user is, send what your app already knows, such as country and anything of your own in custom. Gender is accepted only from an app rated 18+ in its store listing, so leave it out otherwise.
Encore follows the browser language. If your app has its own language picker, also call setLanguage with the user’s choice.
Only pass what you have a lawful basis to share, such as the user’s consent. Pass the user’s age in whole years as age, or their date of birth as dateOfBirth (YYYY-MM-DD), whichever your app has. The SDK works the age out on the device and never sends the date; given both, it uses the lower age. If you hold only a range, send its lowest end as age. A user under 18 is still served offers, from age-appropriate inventory only and with no per-user personalization. See Sending an age.
Attributes power offer targeting and personalization. They merge with existing attributes, so set them incrementally as you learn more about the user:
The supported keys (all optional strings, plus a free-form custom: Record<string, string>) are listed field-by-field in setUserAttributes(). Where you cannot install the SDK in your own app, such as when you open the hosted offer page in a webview, send the attributes with POST /users/attributes instead. Do not assume it behaves like setUserAttributes(). It replaces the stored set on every call rather than merging into it, so send the complete set each time; it takes a whole-number age and refuses dateOfBirth; and the identifier fields need an app rated 18+ in its store listing.

Reset on logout

reset() clears all locally stored SDK state (what gets cleared) and generates a fresh anonymous UUID:
Call it on logout and when switching accounts (then identify() the new user). See reset().

Complete flow

Next steps