Identify

Turn an anonymous visitor into a named person, and keep the history they already built.

Every session starts anonymous with a generated id. identifyUser attaches a real identity to it without discarding what came before, so the sign-up that preceded the account still belongs to the account.

Call it when you know who they are

await tracker.identifyUser({
  email: "alex@example.com",
  name: "Alex Nakamura",
  plan: "pro",
  company: "Northwind",
});

Call it right after sign-in, and again on load for a session that is already authenticated. It is safe to call more than once.

If you do not pass an explicit user id, email becomes the identifier.

In React:

import { useHumanBehavior } from "humanbehavior-js/react";

const tracker = useHumanBehavior();
await tracker.identifyUser({ email: user.email, name: user.name });

Sign out

tracker.logout();

Without this, the next person to use that browser inherits the previous person's identity — a shared or public machine merges two people into one account.

Properties

Everything you pass becomes a filterable attribute on the person. Send what you will want to segment by: plan, company, role, signup date. You can also set one at a time:

tracker.setUserProperty("plan", "enterprise");

Keep secrets out. Properties are analytics data, not a credential store.

Verified identity

A client can claim to be any user, because it is a browser. For projects that require it, your backend mints an identity token and the SDK forwards it:

await tracker.identifyUser(
  { email: user.email },
  { identityToken: tokenFromYourServer },
);

With identity verification required, an identify that claims an external user id without a valid token is rejected. Turn it on in Settings for projects where one user impersonating another would matter.