Identify customers

Link anonymous purchase history to accounts in your authentication system.

Voidhash creates and persists an anonymous distinct ID on first launch. Purchases and events work before sign-in. If your app has accounts, call identify() after authentication so access follows the customer across devices.

Identify after sign-in

Pass a stable identifier from your backend, plus optional profile fields:

await voidhash.client.identify(user.id, {
  email: user.email,
  name: user.name,
});

Use an opaque, unique ID such as a UUID. Do not use an email address or sequential database ID as the primary identifier.

When an anonymous customer signs in, Voidhash moves their purchase history and entitlements to the identified person. Events captured before the switch remain attributed to the anonymous identity.

Sign out

Reset Voidhash after your own sign-out completes:

await auth.signOut();
await voidhash.client.signOut();

signOut() flushes pending events under the old identity and starts a fresh anonymous session. Use reset() only when you need the same identity reset without recording a sign-out event.

Set customer attributes

For background updates, send attributes through the analytics queue:

await voidhash.client.setPersonAttributes({
  email: "ada@example.com",
  name: "Ada Lovelace",
  plan_source: "referral",
});

Call await voidhash.client.flush() when delivery must complete immediately. If you need the updated person in the same request, use setPersonAttributesSync() instead.

Attribute values can be strings, numbers, booleans, or null. email and name map to built-in person fields; other keys become custom traits.

Read the distinct ID

const distinctId = await voidhash.client.getDistinctId();

This is useful in support logs and when correlating a client session with your backend.

Anonymous or identified?

App modelRecommended setup
No accountsKeep the automatically generated anonymous identity.
Optional accountsLet purchases work anonymously, then identify after sign-in.
Account requiredIdentify immediately after restoring your app session.

Next steps