Install
1
Add a web integration
In the cabinet, go to Settings, open Live chat under Channels and click Add Integration. Enter the Domain Address of the site that will host the widget, without
https:// and without a path, for example www.example.com. Leave the widget on Live chat and click Add web integration.2
Copy the inject code
The Integration info dialog shows your Integration Key, your Organization Id and an Inject code snippet with both filled in. Copy the snippet.
3
Paste it into your page
Add the snippet to the
<head> of every page where the chat should appear. The launcher shows up once the page has loaded.The widget only starts on the domain you registered. Clarity checks the page’s origin against the channel’s Domain Address, so a staging site or a second domain needs its own web integration.
Configuration options
Add options to theo object in the snippet. All of them are optional except the two ids.
Callbacks
The snippet passeswindow.onAnecdoteSuccess and window.onAnecdoteError to the widget. Define them before the snippet runs to learn whether the chat session started:
Open and close the chat from your page
The widget has its own launcher. You can also open it from your own Chat with us button, a help link or after a form is submitted. Use whichever form your site can reach:?.() from your own scripts or wait for onAnecdoteSuccess. A command sent before the widget is ready is applied as soon as it is.
To follow the panel’s state, listen for the events the widget posts on every open and close:
These commands work while Host page can open/close the widget is on in the integration dialog. Turn it off and the widget ignores them; its own launcher keeps working.
Identify signed-in visitors
Pass the visitor’s details in the snippet’so object so your team sees who they are talking to:
Verify the visitor (signed identity)
Your backend signs a short-lived JWT for the logged-in visitor with the channel’s identity secret. The widget carries the token to Clarity, which checks the signature and ties the conversation to that user. When the token is valid, its claims take precedence overexternalId and the other identity options.
1
Get the identity secret
Open the web integration in Settings > Live chat. Under Identity verification, click Reveal secret and then Copy secret. Store it in your backend’s configuration.
2
Mint a token on your backend
Sign a JWT with HS256, using the secret exactly as the cabinet shows it. Do not decode it first.Take the
user_id from your server-side session, never from a parameter the browser sends. Otherwise any visitor could request a token for someone else.3
Pass the token to the widget
Fetch a fresh token on every page load and add it to the snippet’s options as
userJwt. The simplest place is the snippet’s onload, which runs once the widget script is available:/api/clarity-token stands for your own authenticated endpoint that returns the token.Logging in and out in a single-page app
If the visitor logs in or out after the widget has started, callanecdoteLiveChatIdentify:
anecdoteLiveChatInit call, so an open panel closes and unsent text is lost. Call it at login or logout, not mid-conversation. { userJwt: null } also drops every identity field and restarts the widget for an anonymous visitor.
The token is checked once, when the session starts. If it expires during a conversation, the conversation carries on.
Require a verified identity
In the same Identity verification section, Require a verified identity refuses any session that states anexternalId without a valid token. Anonymous visitors can still chat. Turn it on only once your backend issues tokens to every logged-in visitor.
Rotate the secret
Rotate secret creates a new secret. The previous one stays valid for 7 days, so tokens your backend still signs with it keep working while you deploy the new one. Revoke previous secret ends that overlap at once.Custom attributes
customAttributes sets attributes on the contact when the widget starts. Values can be a string, a number, a boolean, an array of strings (the option ids of a list attribute) or null to remove the attribute. Define the attributes your team uses in Settings > Custom attributes.
Customize the widget
Settings > Widget controls the widget’s look and texts for every channel:
Your edits are saved as a draft. Click Publish to make them live; History keeps earlier versions.
The web integration’s dialog has per-channel switches: Enable voice calling (with the voice agent that answers), Enable dictation, Show the Inbox tab, Open straight into the conversation, Let visitors verify an email to see their history and Host page can open/close the widget. Click Save changes after editing them.
Troubleshooting
The launcher does not appear
The launcher does not appear
Check that the snippet is on the page and that the page’s domain matches the web integration’s Domain Address exactly. A different subdomain, such as
example.com versus www.example.com, is a different domain. Check the browser console and network tab for a failed request to live-chat.leap.onclarity.com; a Content Security Policy on your site must allow that host for scripts and frames.The session is refused after adding userJwt
The session is refused after adding userJwt
onAnecdoteError receives an object whose code says why:The widget does not retry a refused token on its own.
The Inbox tab is empty
The Inbox tab is empty
The widget lists past conversations only for a visitor it can identify. Pass
externalId or, better, a userJwt, or turn on Let visitors verify an email to see their history.