Listen to live chat events on your website

To help developers connect to analytics tools or react to events in your live chat, the widget sends browser events that your JavaScript code can listen to. You can use these events to send data to external systems, such as analytics platforms, CRM solutions, or your website.

This article explains how to track and pass live chat events.

Event list

The widget tracks browser events when a subscriber or your live chat takes an action, such as when they start a chat, send a message, or click a button.

Each event has its own name and a specific set of data. All events include the standard fields listed below. Some events add more information about subscriber or chatbot actions.

Event When it launches Fields
spLiveChatLoaded A subscriber started a chat in their browser. timestamp, visitorId, phone.
spLiveChatOpened A subscriber opened the widget manually. This event does not trigger if the chat opens automatically. timestamp, visitorId, phone, chatId, subscriberId.
spLiveChatClosed A subscriber closed the widget. timestamp, visitorId, phone, chatId, subscriberId.
spGreetingButtonClicked A subscriber clicked a button in the live chat greeting or menu. The button object, which includes: text, type, id, payload.
spChatInitiated A subscriber sent their first message. The message field — the text of the first message.
spMessageSent A subscriber sent a message. Objects: { message, type: 'text' } for text messages and { fileName, fileType, type: 'file' } for attachments.
spMessageReceived Your live chat sent a message within a flow, or a chat assignee replied. message, type, quick_replies, url.

Each event includes the following fields:

timestamp Event time in ISO format, such as 2025-11-10T14:32:05Z.
visitorId, phone

Subscriber ID.

These fields may be missing if the visitor has not interacted with your live chat or has not provided their information.

chatId Active project ID sent when a subscriber starts a chat.
subscriberId

Subscriber ID assigned after registration.

These fields may be missing if the visitor has not interacted with your live chat or has not provided their information.

Event passing

To confirm that widget events work as expected, you can test them in your browser. Add the script to any page where your live chat is already installed:

<script>
  document.addEventListener('spMessageSent', (event) => {
    console.log('[LiveChat] visitor message sent', event.detail);
  });

  document.addEventListener('spMessageReceived', (event) => {
    console.log('[LiveChat] operator message received', event.detail);
  });
</script>

You can replace the console.log block with your analytics or integration code. Afterward, all live chat events will appear in your browser console.

Rate this article about "Listen to live chat events on your website"

User Rating: 4 / 5 (7)

Next

Set up a Live chat

Popular in Our Blog

Start using free live chat on your website