Measuring

User identity

The one line that unlocks retention and lifecycle — hashed in the browser, never sent raw.

Why it is needed#

Our visitor id is a one-way hash that changes every day — we use no cookies. That has a consequence: cross-day tracking of anonymous traffic is mathematically impossible. The sentence "30% of last week's visitors came back" cannot be constructed from anonymous data.

Rather than fabricate it, we open a second route: while a user is signed in, you give us your own id.

// on every page while the user is signed in (once is enough in a single-page app)
vitrus.identify(user.id);

// optionally with traits
vitrus.identify(user.id, { plan: "pro" });

Calling it before the script has loaded#

The script is deferred, so an early call would find no vitrus yet. Put this one-line stub above the script tag and every call made before it arrives is kept and replayed — including identify:

window.vitrus=window.vitrus||function(){(vitrus.q=vitrus.q||[]).push(arguments)};
vitrus("identify", user.id);

What leaves the browser — and what does not#

  • The raw id never leaves the browser. The script sends sha256(siteId + "|" + id). On a plain-http page without WebCrypto it sends no id at all — never the raw one.
  • The server hashes it again with a secret that never leaves the server, and only that is stored.
  • It is scoped per site. The same user on two of your sites is two unrelated values — nobody can join them.
  • It is persistent (no daily salt) — that is what makes retention and lifecycle possible.
  • It is not stored in the browser. It is lost on reload, which is why you call it on each page.
  • Strict mode ignores it entirely — see privacy mode.

Traits: personal fields are dropped twice#

Traits are sent once, as an identify event. Keys that name personal data — email, phone, first/last name, address, password, token, IP, date of birth, card, IBAN, national id — are dropped, and so is any value shaped like an email address or an international phone number, whatever its key. The browser does it first; the server does it again with the full list, so an edited script changes nothing about what is stored. The event itself is kept, and the Lifecycle page's privacy check says how many properties were removed.

A plan trait is normalised to a short lower-case label (pro, team); anything else is left out with a reason.

From your server or a mobile app#

Send the same pre-hash, and the browser and your backend land on the same person:

// Node / Bun
const identity = createHash("sha256").update(siteId + "|" + userId).digest("hex");

A raw id still works — the server hashes it on arrival and never stores it — but it crossed the network, and the privacy check counts it so you can find the call.

Prefer an opaque id. An email address is hashed in the browser too, but your database's user id is the right thing to send: a hash of a known email can be confirmed by someone who already has that email.
Something wrong or missing on this page? Open an issue or ask in Discussions.