Skip to main content

Text.com Chat GTM Event Listener

Track Text.com (formerly LiveChat) chat widget interactions in GTM. Capture customer_id, customer_email, chat_id, and 7 interaction types with text_action_type variable.

text-comlivechatchatgtmga4supportecommerce

Event fired

text_chat_interactions

Key variable

text_action_type

Text Chat (Text.com)

Overview

Text.com (formerly LiveChat, Inc.'s LiveChat product, now rebranded as Text) is a professional customer service platform. This listener captures extensive customer context, including customer_id, customer_email, customer_isReturning, session variables, and 7 interaction types, making it one of the richest chat listeners available.

Event fired: text_chat_interactions Variables: text_action_type, customer_id, customer_email, customer_name, customer_isReturning, chat_id, thread_id

Why Use This Listener

The customer_isReturning flag lets you segment new vs. returning customer chat interactions. The session_variables capture enables you to pass CRM data into GA4 via the dataLayer.

Tracked Events

text_action_typeDescription
chat_window_visibility_changedWidget shown/hidden
customer_status_updatedVisitor status change
new_eventMessage or file received
form_submittedPre/post-chat form
rating_submittedChat rated
greeting_displayedGreeting shown
rich_message_button_clickedRich message CTA

Installation

html
<!-- GTM Custom HTML Tag: Text.com Listener -->
<script>
(function() {
  function textPush(actionType, extra) {
    var api = window.LiveChatWidget || {};
    var customerData = typeof api.get === 'function' ? api.get('customer_data') : {};
    var chatData = typeof api.get === 'function' ? api.get('chat_data') : {};
    
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push(Object.assign({
      'event': 'text_chat_interactions',
      'text_action_type': actionType,
      'customer_id': customerData && customerData.id,
      'customer_name': customerData && customerData.name,
      'customer_email': customerData && customerData.email,
      'customer_isReturning': customerData && customerData.isReturning,
      'customer_status': customerData && customerData.status,
      'session_variables': customerData && customerData.sessionVariables,
      'chat_id': chatData && chatData.chatId,
      'thread_id': chatData && chatData.threadId
    }, extra || {}));
  }

  window.LiveChatWidget.on('visibility_changed', function(data) {
    textPush('chat_window_visibility_changed', { visibility: data.visibility });
  });

  window.LiveChatWidget.on('customer_status_changed', function(data) {
    textPush('customer_status_updated', { customerStatus: data.status });
  });

  window.LiveChatWidget.on('new_event', function(data) {
    textPush('new_event', { eventType: data.event && data.event.type });
  });

  window.LiveChatWidget.on('form_submitted', function(data) {
    textPush('form_submitted', { form_type: data.type });
  });

  window.LiveChatWidget.on('rating_submitted', function(data) {
    textPush('rating_submitted', { rating_value: data.value });
  });

  window.LiveChatWidget.on('greeting_displayed', function(data) {
    textPush('greeting_displayed', { greeting_id: data.id, greeting_unique_id: data.uniqueId });
  });

  window.LiveChatWidget.on('rich_message_button_clicked', function(data) {
    textPush('rich_message_button_clicked', {
      event_id: data.eventId,
      postback_id: data.postbackId
    });
  });
})();
</script>

Data Layer Output

json
{
  "event": "text_chat_interactions",
  "text_action_type": "form_submitted",
  "form_type": "pre-chat",
  "customer_id": "cust_abc123",
  "customer_email": "jane@example.com",
  "customer_isReturning": true,
  "chat_id": "chat_xyz789",
  "thread_id": "thread_456"
}

Trigger Configuration

Trigger Type: Custom Event Event Name: text_chat_interactions

Variables to Capture

Variable NameDL KeyExample
DLV – Text Action Typetext_action_type"form_submitted"
DLV – Text Customer IDcustomer_id"cust_abc123"
DLV – Text Customer Emailcustomer_email"jane@example.com"
DLV – Text Is Returningcustomer_isReturningtrue
DLV – Text Chat IDchat_id"chat_xyz789"

GA4 Mapping

GA4 EventConditionParameters
chat_widget_openvisibility: maximizedcustomer_id, is_returning
generate_leadform_submitted (pre-chat)customer_email, form_type
chat_ratingrating_submittedrating_value

Best Practices

  1. Use customer_isReturning as a GA4 dimension to compare new vs. returning user chat patterns
  2. Use session_variables to pass UTM parameters from your site into the chat session
  3. customer_email is available after form submission, gate it behind consent

Related Listeners