Skip to main content
The widget reports what visitors do, so you can send it to your own analytics tool. Each event holds metadata only. It never holds the text of a question, an answer, an email address or a note.

Send events to your analytics tool

Pass a function as onAnalyticsEvent 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.
If you keep the standard tag with 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.
If a page has more than one widget, use onAnalyticsEvent. Each widget has its own handler. The legacy window events can only tell the widgets apart through apiBaseUrl.

Events

Each event has a name 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

The widget also dispatches four events on window. Each event carries the fields of the matching analytics event, plus apiBaseUrl, in detail.
  • paperlink-widget:opened
  • paperlink-widget:closed
  • paperlink-widget:message-submitted
  • paperlink-widget:session-created
New code uses onAnalyticsEvent instead.

API keys

Learn how to create, rotate and revoke the key that the widget uses.