identify()
Visitor ids change every day, so on its own the same person is a new Visitor each day (see the
Privacy model). When people sign in to your website, sd.identify() ties their Visits
to your own id for them, so their journey and Funnels can span several days.
Usage
Call it once the person is signed in, with an id from your own system:
sd.identify(user.id);
- Use a stable, opaque id, such as your database's user id. Never an email address or a name.
- The id is up to 256 characters. Calling it with an empty id does nothing.
- Call it on each day the person visits, for example on every page load while they are signed in. It links that day's Visitor; days without a call stay unlinked.
sd.identify() exists once the script has loaded. The stub
queues Events only, so call identify() after the page has loaded.
What is stored
We never store the id you pass. We store an HMAC-SHA-256 hash of it, keyed by a secret that belongs to the Site and never leaves our servers. The same id always gives the same hash for that Site, which is how the days are linked, but the hash cannot be turned back into the id, and it differs between Sites. No traits, emails or other details are stored with it.
What it changes
- Users tab: an Identified visitor keeps one label across days, and its journey covers every day with the same hash, newest 30 days.
- Funnels: an Identified visitor counts as one person across days, so a Funnel with a 7- or 30-day window can follow them from the first step to the last.
- Revenue attribution: a Payment's Source and country come from the payer's first Visit, across days when the payer is identified. See Revenue attribution.
sd.visitorId()
sd.visitorId() returns today's Visitor id from the last response of /collect, or null until the first hit has been
answered. Pass it to your checkout to attribute Payments, as shown in
Revenue attribution.
Consent
identify() links a person's activity across days to an account on your website, so it is personal data. Use it only
where you have a lawful basis, such as signed-in customers who agreed to your privacy policy, and say so in it.