Zoho

From Growth Agency Wiki
Revision as of 14:36, 28 November 2019 by Aaron.trevellick (talk | contribs)
Jump to navigation Jump to search

Tracking In Tag Manager

Zoho has an API for tracking.

https://www.zoho.com/salesiq/help/developer-section/js-api.html

To use this, create a custom HTML tag In tag manager and trigger it on any pages the Zoho chat runs on.

Add this script to the custom HTML:

<script>
function zohoDataLayerEvent( eventName, visitId ) {
	var dataLayer = window.dataLayer || [];
	if (typeof visitId !== 'undefined') {
      dataLayer.push({'visitID' : visitId})
    }
	dataLayer.push({'event' : 'zoho-' + eventName});
}

jQuery(document).ready(function(){

  	if (typeof $zoho !== 'undefined') {
        console.log( 'zoho hook started' );
      	$zoho.salesiq.floatbutton.click(function() { zohoDataLayerEvent( 'chat-open' ); });

		$zoho.salesiq.chatbutton.click(function() { zohoDataLayerEvent( 'chat-start' ); });
      
		$zoho.salesiq.chat.online(function(){ zohoDataLayerEvent( 'chat-online' ); });
		$zoho.salesiq.chat.offline(function(){ zohoDataLayerEvent( 'chat-offline' ); });
		$zoho.salesiq.chat.attend(function(visitid,data){ zohoDataLayerEvent( 'chat-attend', visitid ); });
		$zoho.salesiq.chat.agentMessage(function(visitid,data){ zohoDataLayerEvent( 'agent-message', visitid ); });
		$zoho.salesiq.chat.complete(function(visitid,data){ zohoDataLayerEvent( 'chat-complete', visitid ); });
		$zoho.salesiq.chat.transferchat(function(visitid,data) { zohoDataLayerEvent( 'chat-tranferred' ); });
		$zoho.salesiq.chat.accepttransfer(function(visitid,data) { zohoDataLayerEvent( 'chat-transfer-accepted' ); });
		$zoho.salesiq.chat.continue(function(visitid,data) { zohoDataLayerEvent( 'chat-continue' ); });
    }
});
</script>
  • note we do not use the "$zoho.salesiq.ready" as it is unreliable via tag manager

zoho-chat-online – when visitor is on the page
zoho-chat-open – when the visitor opens the tab
zoho-chat-start – when the visitor starts to use the chat
zoho-chat-attend – when the agent has attended to the chat session
zoho-agent-message – when the agent has sent the visitor a message
zoho-chat-complete – the chat session is complete