Zopim Chat - Track Chats as Conversions - Google Analytics 4

Answered

6 Comments

  • Ed

    Great idea! We definitely need that.

    1
  • Ramin Shokrizadeh
    Zendesk Product Manager

    Hi there Dan,

    Thanks for sharing your feedback. The legacy Chat widget/Zopim widget is not being actively developed now and the team is focusing on the Web Widget/Messaging experience going forward.

    In terms of alternative solutions, you can try and use the callback Javascript API for when a chat has started or ended to then execute the GA command to create a lead: https://developer.zendesk.com/api-reference/widget/chat-api/#on-chatstart 

    Hope that helps unblock what you are hoping to achieve.

    -Ramin

     

    0
  • Dan Barnes

    Hi Ramin,

    There's set on-chat start and isChatting. One fires when a chat started and the other checks if there is a chat session in progress. They seem quite similar. What's the difference?

    Dan

     

    0
  • Ramin Shokrizadeh
    Zendesk Product Manager

    Hi Dan

    They may have some overlap depending on the use case. On Chat start is for the beginning of the chat session and isChatting is true when there is an ongoing chat session. 

    For your use case, most customers use on Chat start to register when the visitor starts the chat request from the widget.

    -Ramin

    0
  • Dan Barnes

    Hi Ramin,

    For the ischatting would this code look right to you? I've followed the instructions to initialize the sdk and wait for connection to be established before consuming api. It doesn't work. I'm assuming it doesnt work because for the google analytics4 gtag.js API to work the global site tag needs to be on the actual page that zopim in loading on. You have a html fragment as the widget (i think) but perhaps that loads on its own separate page that would need the gtag.js global site tag on. There's no way for us to put it our code on that page the widget loads i dont think?

    <!--Start of Zendesk Chat Script-->
    <script type="text/javascript">
    window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
    d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
    _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
    $.src="https://v2.zopim.com/?4axxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";z.t=+new Date;$.
    type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");
    
    //start main zopim function
    $zopim(function() {
    	//start initialize sdk
    	zChat.init({
    		account_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    	});
    	//end initialize sdk
    
    	//Wait for connection to be established
    	zChat.on('connection_update', function(status) {
    		if (status === 'connected') {
    			// Start consuming your API here
    
    			// start check a chat is taking place
    			if (zChat.isChatting()) {
    				//record ga4 lead event, if it is
    				gtag("event", "generate_lead", {
    					currency: "GBP",
    					value: 1
    				});
    				// end ga4 event code
    			}
    			else {
    				// Nothing happening so do nothing
    			}
    			// end check a chat is taking place
    
    		}
    	});
    	//End Wait for connection to be established
    });
     //end main zopim function
    </script><
    !--End of Zendesk Chat Script-->
    0
  • Ramin Shokrizadeh
    Zendesk Product Manager

    You are mixing the Web SDK APIs with the Zopim Widget which doesn't work, you need to use the Zopim Widget Javascript APIs after the widget and GA snippet has been initialised

    Here are the developer docs for the Zopim widget Javascript APIs: https://api.zopim.com/files/meshim/widget/controllers/LiveChatAPI-js.html

    0

Please sign in to leave a comment.

Powered by Zendesk