ChatBot Event Listener
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>