LiveChat: Difference between revisions
Jump to navigation
Jump to search
Created page with "== Tracking In Tag Manager == LiveChat has an API for tracking. https://developers.livechat.com/docs/extending-chat-widget/ this has NOT been tested yet! <pre> <script> (fun..." |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Tracking In Tag Manager == | == Tracking In Tag Manager == | ||
LiveChat has an API for tracking. | LiveChat has an API for tracking.<br /> | ||
https://developers.livechat.com/docs/extending-chat-widget/ | https://developers.livechat.com/docs/extending-chat-widget/<br /> | ||
this has NOT been tested yet! | this has NOT been tested yet!<br /> | ||
<pre> | <pre> | ||
| Line 9: | Line 9: | ||
(function() { | (function() { | ||
function LiveChatDataLayerEvent( eventName ) { | function LiveChatDataLayerEvent( eventName ) { | ||
var dataLayer = window.dataLayer || []; | var dataLayer = window.dataLayer || []; | ||
dataLayer.push({'event' : 'LiveChat-' + eventName}); | dataLayer.push({'event' : 'LiveChat-' + eventName}); | ||
} | } | ||
LiveChatWidget = LiveChatWidget || {}; | LiveChatWidget = LiveChatWidget || {}; | ||
if( LiveChatWidget ) { | if( LiveChatWidget ) { | ||
LiveChatWidget.on('ready', function(){ LiveChatDataLayerEvent('ready'); }); | LiveChatWidget.on('ready', function(){ LiveChatDataLayerEvent('ready'); }); | ||
LiveChatWidget.on('availability_changed', function(data){ LiveChatDataLayerEvent('availability_changed'); }); | LiveChatWidget.on('availability_changed', function(data){ LiveChatDataLayerEvent('availability_changed'); }); | ||
LiveChatWidget.on('visibility_changed', function(data){ LiveChatDataLayerEvent('visibility_changed'); LiveChatDataLayerEvent('visibility_changed_' + data.visibility ); }); | LiveChatWidget.on('visibility_changed', function(data){ LiveChatDataLayerEvent('visibility_changed'); LiveChatDataLayerEvent('visibility_changed_' + data.visibility ); }); | ||
LiveChatWidget.on('customer_status_changed', function(data){ LiveChatDataLayerEvent('customer_status_changed'); LiveChatDataLayerEvent('customer_status_changed_' + data.status ); }); | LiveChatWidget.on('customer_status_changed', function(data){ LiveChatDataLayerEvent('customer_status_changed'); LiveChatDataLayerEvent('customer_status_changed_' + data.status ); }); | ||
LiveChatWidget.on('new_event', function(event){ LiveChatDataLayerEvent('new_event'); LiveChatDataLayerEvent('new_event_' + event.type); }); | LiveChatWidget.on('new_event', function(event){ LiveChatDataLayerEvent('new_event'); LiveChatDataLayerEvent('new_event_' + event.type); }); | ||
LiveChatWidget.on('form_submitted', function(data){ LiveChatDataLayerEvent('form_submitted'); LiveChatDataLayerEvent('form_submitted_' + data.type); }); | LiveChatWidget.on('form_submitted', function(data){ LiveChatDataLayerEvent('form_submitted'); LiveChatDataLayerEvent('form_submitted_' + data.type); }); | ||
LiveChatWidget.on('rating_submitted', function(value){ LiveChatDataLayerEvent('rating_submitted'); LiveChatDataLayerEvent('rating_submitted_' + value); }); | LiveChatWidget.on('rating_submitted', function(value){ LiveChatDataLayerEvent('rating_submitted'); LiveChatDataLayerEvent('rating_submitted_' + value); }); | ||
LiveChatWidget.on('greeting_displayed', function(greeting){ LiveChatDataLayerEvent('greeting_displayed'); }); | LiveChatWidget.on('greeting_displayed', function(greeting){ LiveChatDataLayerEvent('greeting_displayed'); }); | ||
LiveChatWidget.on('greeting_hidden', function(greeting){ LiveChatDataLayerEvent('greeting_hidden'); }); | LiveChatWidget.on('greeting_hidden', function(greeting){ LiveChatDataLayerEvent('greeting_hidden'); }); | ||
LiveChatWidget.on('rich_message_button_clicked', function(data){ LiveChatDataLayerEvent('rich_message_button_clicked'); }); | LiveChatWidget.on('rich_message_button_clicked', function(data){ LiveChatDataLayerEvent('rich_message_button_clicked'); }); | ||
} | } | ||
})(); | })(); | ||
Latest revision as of 16:11, 1 December 2020
Tracking In Tag Manager
LiveChat has an API for tracking.
https://developers.livechat.com/docs/extending-chat-widget/
this has NOT been tested yet!
<script>
(function() {
function LiveChatDataLayerEvent( eventName ) {
var dataLayer = window.dataLayer || [];
dataLayer.push({'event' : 'LiveChat-' + eventName});
}
LiveChatWidget = LiveChatWidget || {};
if( LiveChatWidget ) {
LiveChatWidget.on('ready', function(){ LiveChatDataLayerEvent('ready'); });
LiveChatWidget.on('availability_changed', function(data){ LiveChatDataLayerEvent('availability_changed'); });
LiveChatWidget.on('visibility_changed', function(data){ LiveChatDataLayerEvent('visibility_changed'); LiveChatDataLayerEvent('visibility_changed_' + data.visibility ); });
LiveChatWidget.on('customer_status_changed', function(data){ LiveChatDataLayerEvent('customer_status_changed'); LiveChatDataLayerEvent('customer_status_changed_' + data.status ); });
LiveChatWidget.on('new_event', function(event){ LiveChatDataLayerEvent('new_event'); LiveChatDataLayerEvent('new_event_' + event.type); });
LiveChatWidget.on('form_submitted', function(data){ LiveChatDataLayerEvent('form_submitted'); LiveChatDataLayerEvent('form_submitted_' + data.type); });
LiveChatWidget.on('rating_submitted', function(value){ LiveChatDataLayerEvent('rating_submitted'); LiveChatDataLayerEvent('rating_submitted_' + value); });
LiveChatWidget.on('greeting_displayed', function(greeting){ LiveChatDataLayerEvent('greeting_displayed'); });
LiveChatWidget.on('greeting_hidden', function(greeting){ LiveChatDataLayerEvent('greeting_hidden'); });
LiveChatWidget.on('rich_message_button_clicked', function(data){ LiveChatDataLayerEvent('rich_message_button_clicked'); });
}
})();
</script>
Note, if it creates an error in the console about LiveChatWidget the chat implementation script may need updating