Identify signed-in users

Call identify after sign-in and reset on sign-out so visits, funnels and revenue are tied to real users.

Updated

By default every visitor is anonymous. When your app tells Boostra who a signed-in user is, their visits on every device join one profile in User Profiles, and payments that carry the same id are matched to them.

Call identify once the user is known#

Call it after login, after an OAuth redirect returns, after sign-up, and on app start when a session already exists:

window.boostra?.("identify", { userId: user.id, email: user.email });
  • userId is your stable internal id, such as a UUID or database id. Allowed characters are letters, digits and . _ : @ + -, up to 128 characters. Prefer an internal id over an email address.
  • email is optional. It is hashed in the browser before it is sent; the plain address is only sent when the snippet has data-identity-allow-email="true". An email used as the userId is replaced by its hash in the same way.
  • traits is optional and accepts name, plan, company, role and signupAt.
  • Calling it again with the same id is harmless. A different id starts a new visitor.

Reset on sign-out#

window.boostra?.("reset");

Call it only on a real sign-out. Calling it on every page load for anonymous visitors would start a new visitor each time.

A real example: Supabase Auth#

supabase.auth.onAuthStateChange((event, session) => {
  if (session?.user) {
    window.boostra?.("identify", { userId: session.user.id, email: session.user.email });
  } else if (event === "SIGNED_OUT") {
    window.boostra?.("reset");
  }
});

The same pattern works with Clerk, Firebase, Auth0 and NextAuth: identify when the auth library reports a user, and reset only when a signed-in user signs out.

Automatic recognition#

Without any code, the tracker also tries to recognize signed-in users from common auth libraries and from identify calls you already make to other tools. It never reads access tokens or passwords. To turn it off, add data-identity-auto="false" to the snippet. An explicit identify call always wins.

When sign-in happens on the server#

If your login completes on the server (cookie sessions, magic links, webhooks), identify from there instead: see Identify users from your server.

Never pass access tokens, refresh tokens, passwords, card data or whole user objects to Boostra.

Related articles