ChatBot Event Listener

A chatbot widget helps with customer communication, but understanding how users interact with this tool impacts your business KPIs. All these are possible with the help of this Chatbot event listener and Google Tag Manager.

How to track ChatBot Interactions with google tag manager

You can send ChatBot user interactions data to your Analytics stacks (Google Analytics, Piwik Pro, Mixpanel, etc.) using Google Tag Manager and the ChatBot event listener.

Having this data in your measurement platform, gives you valuable insights into what impact these interactions have on your marketing funnel, conversions, website engagement metrics, and other business KPIs.

Your first step will be to copy, and paste the ChatBot event listener script in the GTM custom HTML tag and fire it on pageview or DOM ready (always recommended).

PRO TIP: if you installed the ChatBot script through Google Tag Manager, please use the DOM-ready trigger instead.

In the next step you should create the [chatBot_Interaction] custom events, which is triggered on every interaction with the ChatBot widget.

DataLayer variable with the key [chatAction] should be created for you to capture in GTM, the ChatBot event type.

[chatAction] returns the following event description;

  • Maximize Chat Widget
  • Minimize Chat Widget
  • Hide Chat Widget
  • Send a Message
  • Start Conversation

You can use the [chatAction] dataLayer variable as event parameters or for streamlining your trigger to fire on specific ChatBot chat interactions.

Connect your marketing tags to the trigger and use the dataLayer variables you created to push more information about each ChatBot chat interaction.

<script>
window.BE_API = window.BE_API || {};
window.BE_API.onChatWindowOpen = function () {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'chatBot_Interaction',
'chatAction': 'Maximize Chat Widget'
});
};
// fires when you minimize chat widget
window.BE_API = window.BE_API || {};
window.BE_API.onChatWindowClose = function () {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'chatBot_Interaction',
'chatAction': 'Minimize Chat Widget'
});
};
// fires when the chat window is hidden
window.BE_API = window.BE_API || {};
window.BE_API.onChatWindowHide = function () {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'chatBot_Interaction',
'chatAction': 'Hide Chat Widget'
});
};
// fires on sending a message
window.BE_API = window.BE_API || {};
window.BE_API.onMessage = function (result) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'chatBot_Interaction',
'chatAction': 'Send a Message',
'Chatmessage': result
});
};
// fires when a conversation is started
window.BE_API = window.BE_API || {};
window.BE_API.onStartConversation = function () {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'chatBot_Interaction',
'chatAction': 'Start Conversation'
});
};
</script>

Video of how to use the listener

Related Event Listener

Wisepops

Measure user interactions and conversions of your Wisepops pop-up using this event listener.

Tidio Chat

Send to your analytics, data of how users interact with your Tidio Chat widget, using GTM and this event listener.

OnWeb Chat

Get insights into how users interact with your OnWeb chat widget using this event listener and GTM.

download the google tag manager recipe for tracking ChatBot Interactions

we make you smarter with data

made with ❤️

The DumbData Team
Before you leave, try out these free tools.
FREE GA4 AUDIT TOOL & UTM AUDIT TOOL