Send events to your analytics tool
Pass a function asonAnalyticsEvent to init. The widget calls it for each event. The script tag has no attribute for this option, so start the widget from your code, as Start the widget from your code explains.
data-api-key, use the legacy window events below.
If your function throws an error, the widget catches it and logs it to the browser console. A broken handler does not break the chat.
Events
Each event has aname and the fields in this table.
length is a number. It does not include the question itself. firstTokenMs is null when no text arrived. reason in answer_feedback_submitted has a value only with a thumbs-down.
Legacy window events
Window CustomEvents
Window CustomEvents
The widget also dispatches four events on
window. Each event carries the fields of the matching analytics event, plus apiBaseUrl, in detail.paperlink-widget:openedpaperlink-widget:closedpaperlink-widget:message-submittedpaperlink-widget:session-created
onAnalyticsEvent instead.API keys
Learn how to create, rotate and revoke the key that the widget uses.