Skip to main content

ChatBot GTM Event Listener

Track ChatBot.com chatbot interactions in GTM. Monitor widget open/close, conversation start, messages, and conversation end with chatAction variable.

chatbotai-chatbotgtmga4automationlead-generation

Event fired

chatBot_Interaction

Key variable

chatAction

ChatBot

Overview

ChatBot (ChatBot.com) is an AI chatbot platform for automating customer service and lead generation. This listener hooks into ChatBot's JavaScript API to track widget interactions and conversation events.

Event fired: chatBot_Interaction Variable: chatAction

Tracked Events

chatActionDescription
widget openedChatbot panel expands
widget closedChatbot panel closes
conversation startedChat initiated
message sentVisitor sends message
message receivedBot responds
conversation endedSession complete
button clickedQuick reply button clicked
form submittedChatbot form completed

Installation

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

  var initChatBot = function() {
    if (typeof window.ChatBotWidget === 'undefined') return;
    ChatBotWidget.on('chat:open', function() { chatbotPush('widget opened'); });
    ChatBotWidget.on('chat:close', function() { chatbotPush('widget closed'); });
    ChatBotWidget.on('conversation:start', function() { chatbotPush('conversation started'); });
    ChatBotWidget.on('message:sent', function() { chatbotPush('message sent'); });
    ChatBotWidget.on('message:received', function() { chatbotPush('message received'); });
    ChatBotWidget.on('conversation:end', function() { chatbotPush('conversation ended'); });
    ChatBotWidget.on('button:click', function(data) {
      chatbotPush('button clicked', { buttonLabel: data.label });
    });
    ChatBotWidget.on('form:submit', function(data) {
      chatbotPush('form submitted', { formData: data });
    });
  };

  window.addEventListener('load', initChatBot);
})();
</script>

Data Layer Output

json
{
  "event": "chatBot_Interaction",
  "chatAction": "conversation started"
}

Trigger Configuration

Trigger Type: Custom Event Event Name: chatBot_Interaction

GA4 Mapping

GA4 EventConditionParameters
chat_widget_openchatAction = widget openedchat_platform: "chatbot"
generate_leadchatAction = form submittedmethod: "chatbot"

Related Listeners