Identify Visitors
Link a consented visitor's sessions to an identity after login, signup, or consent.
Identify a visitor
By default, Hardal tracks anonymous sessions. After a visitor grants consent and logs in or signs up, you can send identity fields. Hardal can then preserve the supplied user ID and recognize later activity for the same tenant and source.
Only identify a visitor who has granted consent. Without consent, Hardal keeps the session anonymous. See Consent Signals.
<script>
hrd.identify("USR_8827", {
email: "alex@example.com",
firstName: "Alex",
lastName: "Rivera"
});
</script>
The first argument is your stable user or customer ID. The second argument contains optional traits. Calling hrd.identify() with only an object sends traits but does not set userId.
Server-side identify calls use "type": "identify", "eventName": "identify", and payload.userId. See Send Events API for the full payload shape.
Verify identity on subsequent activity
- Use a test visitor who has granted consent and a non-personal test user ID.
- Call
hrd.identify()after the tracker is loaded and the application's login or signup succeeds. - Trigger a subsequent event and open it in Engagement → Events.
- Inspect its identity and related session to confirm the expected fields.
userId is your account identifier; visitorId and session ID serve different collection and reporting purposes. Recognition depends on the available identity and collection context; cross-device, cross-source, and cross-domain linking should be verified separately. See Sessions and Visitors.
Choose only the identity traits you need and are permitted to collect. The field reference is not a recommendation to send every available trait.
Identify fields
When to identify a visitor
Call hrd.identify() immediately after a visitor:
- logs in
- signs up
- gives consent while already signed in
With granted consent, future collected events can carry the same visitor identity.