Identifying your users
Attach your own pseudonymous user ID to events with oa.identify, and what that changes.
What identify does
By default every visitor is anonymous and the identifier expires daily, so nobody, including us, can follow a person across days. If your site has signed-in users, you can opt into recognising them: attach your own stable reference to their events, and a returning signed-in user reads as the same person across visits.
oa.identify("user_8f21c4");From that moment the visitor's events carry your reference, hashed, site-scoped and never stored raw, and revenue can be joined through Stripe's client_reference_id or Polar's external_id (see revenue attribution, the fallback recipe).
Wire it in two steps
Ask for consent, because this one needs it
Recognising a person across visits is not ordinary audience measurement, so the reasoning that lets most sites run this script without a banner does not cover this call. You are the controller for it. Decide how you ask, a banner or a preference centre, then tell the script the answer:
oa.consent("granted");Call identify only after consent
Calling oa.identify() after your own consent check is the straightforward pattern, and the one our privacy-notice template describes for site owners. The script sends what your code tells it to; we do not hold it back on a consent state we cannot see.
The rules
- The ID is yours: an internal account number or a database key. Our terms require it not be directly identifying, so no emails and no names.
- It is hashed before storage with a site-scoped key, so the same reference on two sites produces unrelated values.
- 1 to 128 characters. The identify event itself is always free; it never counts against your plan.
- Unlike the anonymous identifier, it does not rotate daily. That is its purpose, and your own privacy notice should say you use it.
What it does not do
It never relabels the past, and never merges sites