HelpAlive.identify() is the call that tells HelpAlive who is signed in to your app. The agent appears only after it runs. Below is every field of identify(), and when to call reset().
Prerequisites
- The HelpAlive tag is in the head of every page. See Install the script.
- You have decided which id to use for users and, if your app has them, for companies.
When to call identify()
Call it wherever your app already knows the signed-in user, as early in each page load as you can. Calling it again with the same details is safe. Keep these four lines above your first call. They queue your calls until our script loads, and our script replays them in order:The call
Pick the tab that matches your app. Settings → Setup & API Key shows the same two calls.- B2B: users belong to tenants
- B2C: users have no tenant
A tenant is one of your customers: the company, workspace or account a user belongs to in your app.
tenantId and tenantName say which tenant each user belongs to. Key concepts defines it with the other terms.Apps with both
Pass the tenant only for users who belong to a company or workspace. Leave it out for users who sign up on their own:Types matter
userIdandtenantIdcan be text or a number.42and"42"are the same person.- Pass
displayName,email,roleandplanas text. A number indisplayName,roleorplanis turned into text. - A field of another type, or one too long, is left out, and the call goes on without it. Keep
roleandplanshort: a name, not a description. - A
userIdortenantIdthat isn’t text or a number, or is over 255 characters, stops the call. An emptyuserIdstops it too. The agent then doesn’t load on that page.
data-debug to the tag to see them in the browser console.
What the agent uses
The agent reads the user’s display name, role, plan and sign-up date, so it can fit its answers to them. It never receives theemail field, but it does see an email you pass as displayName. The fields also label the user in your dashboard, for example in Audience.
Logging out
Callreset() in your logout code, separate from your identify() call. Also call it wherever your app ends a session (for example, where a request comes back signed out):
reset() forgets the user, their tenant and their token. It closes the agent and clears its conversation and the person’s session from the browser. The next person on the same browser finds nothing of the previous person’s.
Never put reset() straight after identify(): it would forget the user at once, and the agent would never appear.
If your logout navigates away before reset() runs, HelpAlive still notices when a different user is identified on that browser. It closes the previous user’s agent first, and sends nothing the previous user gave identify() for the new one.
Some apps let people sign in and out without a page load. If yours does and you can’t change its login or logout code, see Can’t edit your app’s login code? under Single-page apps.
Switching company without reloading
If users can switch company or workspace without a page reload, callidentify() with the new tenantId after the switch. HelpAlive then counts their activity under the new tenant and reloads the agent for it.
If you verify users, the tenant comes from the user token. Pass identify() a new token for the new company from your server.
Before identify() runs
Untilidentify() runs, events wait in the page, and are dropped if the visitor leaves without signing in. The only request before sign-in is a small start-up check. It sends our script’s version and the page’s host and path. But if someone signed in earlier in that browser and your logout code didn’t call reset(), HelpAlive may send events as that person.
Check it works
Sign in to your app and click around, then come back to Settings → Setup & API Key. Step Add HelpAlive to your app gets a check and says when it last saw a signed-in user. The user also appears in Audience, under their tenant or B2C customers. If step 1 keeps saying no signed-in user yet, Troubleshooting lists what to check.Next
Verify users
Optional, and recommended before you open the agent to all your users.
Consent
Wait for your cookie banner before loading HelpAlive.
JavaScript reference
Every call and attribute.

