Zopim Chat Event Listener
How to track Zopim Chat Interactions with google tag manager
Using Google Tag Manager and this event listener script, you can track Zopim chat activity and have the data available in your analytics stack, Google Analytics, Piwik Pro, Mixpanel, Fullstory, Amplitude, etc.
To achieve this, you’ll have to copy this Zopim Chat event listener script and paste it into a new custom HTML tag type in Google Tag Manager, and add a trigger to fire the code on pageview or DOM ready (recommended).
💡 Pro Tip: fire on DOM ready if you implemented the Zopim chat widget through GTM).
The next step is to create a dataLayer variable [zopimChatAction] which tells us what chat activity occurred.
After creating the variable, you should create a custom event trigger with the event name [zopimChat], which fires on every Zopim chat activity.
The event captures chat activities like;
- The user starts a chat
- The user closed a chat
- The Zopim chat widget is visible (expanded)
- The Zopim chat widget gets minimized
Now that you’ve created the trigger, you can now link your marketing tags to this trigger and use the [zopimChatAction] dataLayer variable, to dynamically capture the activity type that happened.
🏆 Credit:
The original code creator is Julius Fedorovicius (we only extended the number of actions the script can track)
<script> $zopim(function() { $zopim.livechat.setOnChatStart(function() { // trigger when chat starts window.dataLayer.push({ "event": "zopimChat", "zopimChatAction": "zopim Chat Started" }); }); $zopim.livechat.setOnChatEnd(function() { // trigger when chat closes window.dataLayer.push({ "event": "zopimChat", "zopimChatAction": "zopim Chat Closed" }); }); $zopim.livechat.window.onShow(function() { // trigger when the chat window is shown window.dataLayer.push({ "event": "zopimChat", "zopimChatAction": "zopim Chat Visible" }); }); $zopim.livechat.window.onHide(function() { // trigger when the chat window is shown window.dataLayer.push({ "event": "zopimChat", "zopimChatAction": "zopim Chat Hidden" }); }); }); </script>