LiveChat

From Growth Agency Wiki
Jump to navigation Jump to search

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