Skip to main content
The web chat widget adds a chat launcher to your site. Visitors talk to your AI agent and your team, and every conversation arrives in your Clarity inbox as a ticket.

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 snippet looks like this:
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 the o object in the snippet. All of them are optional except the two ids.

Callbacks

The snippet passes window.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:
The functions exist only once the widget script has loaded, so call them with ?.() 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’s o object so your team sees who they are talking to:
Values passed this way are a claim the page makes about itself. Anyone can edit page code, so Clarity never treats them as proof of identity. To prove who the visitor is, add a signed token.

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 over externalId 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.
Include email or phone only if your system has verified that the user controls them. A valid token links the chat to any existing contact with that email or phone, including that contact’s history from other channels. The payload is signed, not encrypted, so put nothing in it you would not show the visitor.
The identity secret must never appear in your frontend code. Anyone who has it can sign in as any of your visitors.

Logging in and out in a single-page app

If the visitor logs in or out after the widget has started, call anecdoteLiveChatIdentify:
It restarts the widget with the new token and the parameters of your last 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 an externalId 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.
Turn off Show the Inbox tab if your visitors are not signed in. The widget can list past conversations only for a visitor it can identify.

Troubleshooting

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.
Make sure Host page can open/close the widget is on in the integration dialog. If you call window.anecdoteLiveChatOpen() from your own script, it exists only after the widget script has loaded: use window.anecdoteLiveChatOpen?.(), the data-anecdote-live-chat attribute, or postMessage, which queue the command until the widget is ready.
onAnecdoteError receives an object whose code says why:The widget does not retry a refused token on its own.
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.