Skip to main content

What is user identification?

By default, every event tracked by Analytiq is anonymous — you can see that a button was clicked, but not who clicked it. identify() links all future events to a specific user. After you call it, every track() event is automatically tagged with that user’s ID — so on the dashboard you can filter events by user, see a single user’s journey, and understand your users individually.

When to call identify()

Call identify() in exactly one place: right after login or signup succeeds.

Basic usage

You can use:
  • A database UUID or integer ID: identify('550e8400-e29b-41d4-a716-446655440000')
  • An email address: identify('john@example.com') (only if emails are unique)
  • Any unique string your system uses

After signup

If you used the analytics.jsx “One-File Setup” from the Quickstart, you don’t need to call identify manually.When your user signs up successfully, your app’s authentication state changes. The useEffect inside your analytics.jsx file detects the new user and calls identify() for you automatically.
components/Signup.jsx

After login

Just like signup, you don’t need to call identify manually.When the login succeeds and you update your user state, the useEffect in your analytics.jsx file automatically fires identify().
components/Login.jsx

When the user is already logged in (page refresh)

If your app keeps users logged in, you need to re-identify them when the app loads after a page refresh — otherwise events after a refresh won’t be linked to their identity.
This is handled automatically. When your app loads, your useAuth hook automatically fetches the user from local storage or cookies. Because that variable updates, the useEffect inside analytics.jsx runs again and successfully calls identify() automatically.

Resetting on logout

When a user logs out, their identity must be cleared so the next person using the device doesn’t inherit it.
This is handled automatically. When you clear your user state, your auth hook becomes empty. The useEffect inside analytics.jsx detects this and automatically calls reset().You do not need to call reset() manually inside your Logout button if you have the analytics.jsx file installed perfectly.

How identity flows through events

After identify() is called, all subsequent track() calls are automatically linked:

What NOT to do


Anonymous events before identify()

Any events tracked before identify() is called are stored anonymously. Once you call identify(), future events are linked — but past anonymous events remain anonymous. This is expected behavior.

Tracking anonymous visitors (no login required)

If your app or website has users who never log in (a marketing landing page, a blog, a documentation site), identify() is never called naturally — and all events will have userId = null, meaning they won’t appear in your Unique Users, DAU, or MAU counts. The fix is to generate a stable visitor ID using localStorage. This creates a unique ID the first time someone visits, stores it in their browser, and reuses it on every future visit — all without requiring any login.
Add this to your analytics.jsx provider file, before or alongside the useAuth identify logic:
src/analytics.jsx
How this works: crypto.randomUUID() generates a unique ID (like "f47ac10b-58cc-4372-a567-0e02b2c3d479") the very first time someone visits. It is saved in localStorage so future visits by the same person reuse the same ID — giving you accurate repeat visitor counts.
This visitor ID is device and browser specific. If the same person visits from Chrome and Safari, they will appear as two different visitors. This is expected for anonymous tracking — it is the same behavior used by most analytics platforms for unauthenticated users.