Quick tipDeveloperSmart CRM

Identify logged-in visitors in HubSpot chat with the visitor identification API

If your site has its own login, the chat widget can treat signed-in users as known contacts.

Subscription
Professional or Enterprise
Permissions
Private app or service key with the right scope
Time
5 min · Advanced
Last verified

Short answer

From your server, call POST /visitor-identification/v3/tokens/create with the signed-in user's email. On the page, set loadImmediately: false, then identificationEmail and identificationToken on window.hsConversationsSettings, and load the widget. Tokens expire after 12 hours and must be set on every page load. The API needs a Professional or Enterprise subscription; otherwise it returns 403.

1. Server side

POST https://api.hubapi.com/visitor-identification/v3/tokens/create
{ "email": "visitor@example.com", "firstName": "Pat", "lastName": "Lee" }

Only do this after your own system has verified the user. Never generate tokens from the browser.

2. Page side

window.hsConversationsSettings = {
  loadImmediately: false,
  identificationEmail: "visitor@example.com",
  identificationToken: "TOKEN_FROM_YOUR_SERVER"
};
window.HubSpotConversations.widget.load();

Set the settings object before the widget loads, or you can get a race where the widget starts anonymous.

3. Related

Chat setup: website chatflows and inbox channels.

Sources

New field notes by email

One email when a new article publishes.

Still stuck?

If this did not fix it, the problem is probably specific to your setup. Book a call and we will look at it together.

Book a call with Sam