identify()
Attach a user ID, name, email and custom traits to a visitor.
Identify your users to turn anonymous sessions into recognisable people. By default every
visitor is anonymous. Call NudgeVisor.identify() once you know who someone is — typically right
after they log in — to tag their session replays, chats and live presence with a real name, email and any
custom attributes you care about.
Signature
identify(userId)
identify(userId, traits)
Parameters
| Parameter | Type | Description |
|---|---|---|
userIdrequired |
string | number |
Your own unique identifier for the visitor — a database ID, email, or username. Stored as the visitor's external ID and shown wherever the visitor appears. |
traitsoptional |
object |
An optional, serializable object of additional details. name and email are reserved; every other key is stored as a custom attribute. |
Identify with just an ID
The minimum is a single identifier. The visitor's sessions are now searchable and labelled by this ID.
NudgeVisor.identify('USER_ID');
Identify with traits
Pass a second object to attach a name, email and any custom attributes. Strings and numbers are both supported.
NudgeVisor.identify('USER_ID', {
name: 'Ada Lovelace',
email: '[email protected]',
plan: 'Premium',
currency: 'USD',
mrr: 150,
});
Reserved keys
Two keys are treated specially and power the visitor's display name everywhere in NudgeVisor:
name— shown as the visitor's display name.email— shown beneath the name and is searchable.
Every other key in traits is stored as a custom attribute and listed on the visitor's profile.
The display name falls back through name → email → userId → "Anonymous visitor", so a visitor
identified by ID alone is still recognisable.
Updating attributes later
Use setAttributes() to add or change custom attributes without re-identifying. See the
setAttributes() reference for details.
// Already identified, or want to enrich an anonymous visitor:
NudgeVisor.setAttributes({
plan: 'Enterprise',
seats: 25,
});
Anonymous vs identified visitors
Visitors are tracked anonymously from their very first page view — you keep the full session even if you
never identify them. When you call identify(), the existing anonymous activity is merged onto the
identified visitor, so replays and chats recorded before login are retained and relabelled.
Where to find the snippet
A copy-paste version of these calls sits right under your widget install snippet on each site's page in the dashboard. New to the widget? Start with Installing the widget.