Tracking/Identifying users

Identifying users

Link anonymous devices to real accounts so one person shows up as one journey, from the first blog visit to the paid subscription.

How identity works

Every browser gets a random anonymous id when the SDK first loads. All events carry that id. When you call identify with your own user id, Analyse links the anonymous history on that device to the person. Events sent afterwards are attributed to them directly.

ts
import { identify } from "@analyse.net/sdk";

identify("user_123");

Call it right after signup and after every login. Calling it repeatedly with the same id is fine.

Traits

Pass traits to fill in the person's profile in the Users view:

ts
identify("user_123", {
  name: "Robin",
  email: "[email protected]",
  plan: "pro",
});

name, email, and avatarUrl are lifted into the profile header. Everything else is stored as custom traits, and you can filter on them.

Cross device stitching

If the same person identifies on two devices, both anonymous histories end up under one profile. The Users view shows every device id that has been linked to the person.

Logging out

Call reset() when a user logs out, especially on shared machines. It clears the identity and the session and flushes pending events. The next visitor on that browser starts with a fresh anonymous id.

ts
import { reset } from "@analyse.net/sdk";

reset();
Note

Analyse is cookieless and tracks nothing personal until you call identify. That call is your explicit opt in to storing user data, so make sure it lines up with your own privacy policy. More in Privacy.