Skip to main content

LiveChat GTM Event Listener

Track LiveChat widget interactions in Google Tag Manager. Monitor window open/close, messages, form submissions, ratings, and greeting interactions. Capture chatAction and greetingId.

livechatchatgtmga4supportecommerce

Event fired

livechat interaction

Key variable

chatAction

LiveChat

Overview

LiveChat (LiveChat, Inc.) is a popular customer service platform. This listener uses LiveChat's JavaScript API (LiveChatWidget) to track 12+ distinct interactions including visibility changes, greeting displays, form submissions, message exchanges, and chat ratings.

Event fired: livechat interaction Variables: chatAction, greetingId

Tracked Events

chatAction ValueTrigger
chat window maximizedVisitor expands chat
chat window minimizedVisitor minimizes
chat window hiddenChat hidden
pre-chat survey submittedPre-chat form
post-chat survey submittedPost-chat rating
ticket form submittedOffline ticket
new message sentVisitor message
new event receivedRich event received
greeting displayedProactive greeting shown
greeting hiddenGreeting dismissed
greeting button clickedGreeting CTA clicked
rating submittedChat rated
rich message button clickedRich message interaction

Installation

html
<!-- GTM Custom HTML Tag: LiveChat Listener -->
<script>
(function() {
  function lcPush(action, extra) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push(Object.assign({
      'event': 'livechat interaction',
      'chatAction': action
    }, extra || {}));
  }

  window.LiveChatWidget.on('visibility_changed', function(data) {
    var actions = { maximized: 'chat window maximized', minimized: 'chat window minimized', hidden: 'chat window hidden' };
    lcPush(actions[data.visibility] || data.visibility);
  });

  window.LiveChatWidget.on('form_submitted', function(data) {
    var formActions = { 'pre-chat': 'pre-chat survey submitted', 'post-chat': 'post-chat survey submitted', ticket: 'ticket form submitted' };
    lcPush(formActions[data.type] || 'form submitted');
  });

  window.LiveChatWidget.on('new_event', function(data) {
    if (data.event.type === 'message') lcPush('new message sent');
    else lcPush('new event received');
  });

  window.LiveChatWidget.on('rating_submitted', function(data) {
    lcPush('rating submitted', { chatRating: data.value });
  });

  window.LiveChatWidget.on('greeting_displayed', function(data) {
    lcPush('greeting displayed', { greetingId: data.id });
  });

  window.LiveChatWidget.on('greeting_hidden', function(data) {
    lcPush('greeting hidden', { greetingId: data.id });
  });

  window.LiveChatWidget.on('rich_message_button_clicked', function(data) {
    lcPush('rich message button clicked', { chatButtonText: data.element.label });
  });
})();
</script>

Fire on: Window Loaded. Requires LiveChatWidget to be initialized.

Data Layer Output

json
{
  "event": "livechat interaction",
  "chatAction": "greeting displayed",
  "greetingId": "greeting_123"
}

Trigger Configuration

Trigger Type: Custom Event Event Name: livechat interaction

Conversion-specific:

Condition: DLV – Chat Action | matches RegEx | (pre-chat survey submitted|new message sent)

Variables to Capture

Variable NameDL KeyExample
DLV – LiveChat ActionchatAction"new message sent"
DLV – LiveChat Greeting IDgreetingId"greeting_123"
DLV – LiveChat RatingchatRating"good"

GA4 Mapping

GA4 EventConditionParameters
chat_widget_openchat window maximizedchat_platform: "livechat"
generate_leadpre-chat survey submittedchat_platform
chat_ratingrating submittedrating_value

Related Listeners