Tawk.to is getting popular very quickly as a free chat web application. Here’s an easy way to add the service to your website through Google Tag Manager and send an event to Google Analytics when a chat starts.
Let’s begin by adding the Tawk.to widget to our site with GTM. Go to Admin and copy your widget code:
Now we’ll create a custom HTML tag in GTM and fire it on all pages.
This will show the Tawk.to chat pop up on every page of the site.
Let’s add the chat interaction tracking in another custom HTML tag:
Here’s the code I’m using:
<script type="text/javascript"> Tawk_API.onChatStarted = function(){ if(Tawk_API.isVisitorEngaged()){ window.dataLayer = window.dataLayer || []; window.dataLayer.push({'event': 'chat-started'}); } }; </script>
There’s also Tag Sequencing setting to fire our main Tawk.to tag before this Tawk.to engagement tag.
And the last tag we’ll create is the GA event tag for chat interaction, which will fire on the chat-started event:
We can go to Preview mode and test it. When we started a chat, the chat-started event appeared in the events column of the GTM Debug console and our Chat engagement GA tag was fired:
We also see the event coming in Google Analytics real-time reports:
From here you can use the event to setup a goal in GA, import it into AdWords or add AdWords / Facebook conversion tracking for the chat interaction activity. Hope you’ll find this useful and try it yourself.