Overview
identify() links all future track() calls to a specific user. Call this after a user logs in. This lets you see which events belong to which user on your dashboard.
React / Next.js users: If you are using the
useAnalytiq() hook and passing userId: user?.id, you do not need to call identify() manually. The hook calls it automatically whenever your userId changes. You only need identify() if you are using Vue, Vanilla JS, or another non-React framework.Signature
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | A unique identifier for the user. Can be their database ID, email, or any unique string. |
Example
When to call it
- React / Next.js
- Vue / Vanilla JS
If using the
useAnalytiq() hook, you don’t need to call identify(). Just update your authentication state, and the hook handles it.What happens after identify()
Everytrack() call after identify() will automatically include the userId:
Important rules
If you don’t call
identify(), events are still tracked — they just won’t be linked to a specific user. This is fine for anonymous visitor tracking on the Overview and Events pages only.- Call
identify()once per session, right after login - The identity persists until
reset()is called - You can call
identify()again with a different ID to switch users (rare case)
Reset identity on logout
When the user logs out, callreset() to clear their identity:
reset(), the next user to log in on the same browser session would have their events attributed to the previous user.