Kustomer Event Listener
How to track User Interaction With Kustomer Chat with google tag manager
You can track your website visitors’ interactions with the Kustomer chat widget using Google Tag Manager (GTM) and the Kustomer chat event listener. To do this, start by creating a new custom HTML tag in GTM and paste the Kustomer chat event listener code into this tag.
Next, you’ll need to attach a trigger to your tag. Make sure the trigger fires after the chat widget has loaded on the site; this can be set to trigger on DOM Ready or Window Loaded.
Once the Kustomer event listener is added, it will begin registering dataLayer events for various user interactions with the chat widget.
The following step involves setting up a custom event trigger in GTM, where you’ll add “Kustomer_Chat_Event” as the event name in the trigger. This event name is emitted for all chat interactions tracked by the event listener.
You’ll also need to create a variable in GTM using the “Data Layer Variable” type and set “chat_Action” as the key. This will allow you to dynamically capture different chat actions performed by visitors, such as:
- Kustomer chat widget open
- Kustomer chat widget close
- Kustomer chat conversation create
- Kustomer chat unread count change
After creating the variable, you can start sending this data to your analytics platform, such as Google Analytics (GA4), Piwik Pro, etc.
The Kustomer chat event listener can also be used with other tag management solutions by following the same principles outlined above, enabling you to track Kustomer Chat interactions in platforms like Google Analytics (GA4), Piwik Pro, etc.
To expedite the setup process, you can download a GTM recipe, which you’ll find by scrolling down this resource page.
<script> // Ensure the dataLayer array is initialized window.dataLayer = window.dataLayer || []; // Function to push dataLayer events function pushDataLayerEvent(action) { window.dataLayer.push({ 'event': 'Kustomer_Chat_Event', 'chat_Action': action }); } // Add listeners for Kustomer chat events Kustomer.addListener('onOpen', function(callbackResponse) { pushDataLayerEvent('kustomer chat widget open'); }); Kustomer.addListener('onClose', function(callbackResponse) { pushDataLayerEvent('kustomer chat widget close'); }); Kustomer.addListener('onConversationCreate', function(callbackResponse) { pushDataLayerEvent('kustomer chat conversation create'); }); Kustomer.addListener('onUnread', function(callbackResponse) { pushDataLayerEvent('kustomer chat unread count change'); }); </script>