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_InteractionKey variable
chatActionChatBot
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
| chatAction | Description |
|---|---|
widget opened | Chatbot panel expands |
widget closed | Chatbot panel closes |
conversation started | Chat initiated |
message sent | Visitor sends message |
message received | Bot responds |
conversation ended | Session complete |
button clicked | Quick reply button clicked |
form submitted | Chatbot 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 Event | Condition | Parameters |
|---|---|---|
chat_widget_open | chatAction = widget opened | chat_platform: "chatbot" |
generate_lead | chatAction = form submitted | method: "chatbot" |