Resources/Developer & SDK/Identify logged-in users

Identify logged-in users

Attach a stable user ID and traits to a visitor with Spectry.identify().

By default every visitor gets an anonymous ID. When a user signs in, call identify() to attach a stable identifier and traits so their activity is unified across devices and sessions.

Spectry.identify()

Spectry.identify('user_123', {
  email: 'jane@example.com',
  name: 'Jane Doe',
  plan: 'premium',
  signup_date: '2026-01-15',
});
  • The first argument is your user ID (the same one your app uses).
  • The second is an optional traits object — arbitrary key/value pairs.
  • The call sends the anonymous ID alongside the user ID, so the visitor's earlier anonymous activity is merged into the identified profile on the backend.

When to call it

  • Right after a user logs in or signs up.
  • On every page load for an already-authenticated user (it's safe to call repeatedly).

Traits are overwritten, not merged

Each call replaces the stored traits with what you pass. Send the full trait set every time rather than one changed field, or you'll erase the rest.

Resetting on logout

Spectry.resetIdentity();

This clears the stored user ID and traits and generates a fresh anonymous ID, so the next person on a shared device starts as a genuinely new visitor rather than inheriting the previous one's history. Call it in your logout handler — forgetting to is the usual reason one profile accumulates several people's sessions.

Identity is stored in localStorage. Never pass passwords, tokens or other secrets as traits — traits are visible in the dashboard and included in GDPR exports.

Where it shows up

Identified users appear under People with their traits, event timeline and sessions. See identify & traits for how the dashboard side works.


Put this to work on your own site.

Heatmaps, session replays, funnels and experiments in one platform. Set it up in minutes, no credit card needed, and early-access members earn exclusive rewards.