Skip to main content
Use the tracking script’s browser identity API when your app knows who the visitor is. Call identify() after login or signup, update profile traits with setTraits(), and clear the stored ID on logout.
Browser identity is keyless. Do not put an API key in your frontend bundle.

Available identity methods

Identify after login

Call identify() as soon as your app knows the signed-in user’s stable internal ID:
string
required
Your stable ID for the user, up to 255 characters. Prefer an internal database ID over a value that can change.
object
Optional profile attributes. The serialized object can be up to 2 KB.
TinyAnalytics stores the ID in the browser’s localStorage, so the user stays identified across page loads and later sessions on that device. It also attributes the visitor’s recent anonymous events to the identified user.

Update traits

Once the user is identified, call setTraits() whenever a profile value changes:
Traits merge with the existing profile. Keys you omit stay unchanged, and a key set to null is deleted. If no user is identified, setTraits() does nothing and writes a warning to the browser console.

Read and clear the current identity

Use getUserId() when another client-side integration needs the same ID. Clear it as part of your logout flow so another person using the browser does not inherit the previous identity.
Anonymous measurement does not store an analytics ID in the browser. Identified mode is different: the user ID and traits you send are stored personal data. Choose a lawful basis, disclose the processing, and send only the traits you need. See Privacy & GDPR.

Verify

1

Identify a test user

Sign in to your app in a browser and trigger the client-side identify() call.
2

Open the user profile

Open Users in TinyAnalytics and select the test user. Confirm the profile uses your user ID and shows the traits you sent.
3

Test a trait update and logout

Call setTraits() and confirm the changed value appears on the profile. Log out, then check in the browser console that window.tinyanalytics.getUserId() returns null.
The client-side identity integration is working when the profile uses your stable ID, trait changes appear, and logout clears the ID from the browser.

Identify users

Understand identity behavior, backfill, and consent.

Browser events

Send events that belong to the identified user.

Group & B2B analytics

Associate a visitor with an account from the browser.

Analytics filters

Filter reports by the traits you attach.