How to set up tawk.to for Google Analytics tracking
Use Google Analytics to track tawk.to activity on your site — for example, when a chat starts, ends, or when a new ticket is created.
You can send these events directly to Google Analytics (via gtag) or use Google Tag Manager (GTM) to manage tags and triggers. This guide provides the simplest approach and includes an example you can adapt.
Before you start
You’ll need:
A Google Analytics account and property
A tawk.to account with the chat widget already installed on your website
Tip: If your widget isn’t installed yet, see this guide: Adding the tawk.to widget to your website
Set up the Google tag on your website
Note: If you already added the Google global site tag to your website, skip this step.
1. Sign in to Google Analytics and go to Admin → Setup Assistant under your Property.


2. Click Data collection → Web and create a new data stream for your site. Enter your website’s URL and desired Data Stream name. Then, click Create stream.


3. Under Install manually, copy the global site tag (gtag.js) code provided.

Track tawk.to events in Google Analytics
Next, use the tawk.to API to send chat activity events to Google Analytics with gtag().
Note: Ensure the following code is placed after your tawk.to widget code in your website’s HTML. This ensures the Tawk_API object is available when events are triggered.
Here’s an example you can adapt for your own setup:
You can modify the event names or labels based on your reporting needs. For example, you might track when a ticket is created or when a visitor joins a chat queue.
Track events using Google Tag Manager (optional)
If you prefer to manage tracking in one place, use Google Tag Manager (GTM) instead of adding code directly to your pages.
With GTM, you can:
Trigger Google Analytics events without editing your site code
Test and manage tags in a single dashboard
See this guide to learn more:
How to set up tawk.to for Google Analytics 4 tracking with Google Tag Manager
Additional considerations
Run your code after the widget loads
Ensure your event handlers are added after the tawk.to widget has loaded. If needed, use Tawk_API.onLoad to delay event setup until the widget is ready.Test your setup
Open your site in an incognito window and start a test chat. Then, check Realtime or DebugView in Google Analytics to confirm the event appears.Stay consistent
Use clear and consistent event names (for example, chat_started or offline_message) for easier reporting.Single-page or multi-domain sites
If your site uses client-side routing or spans multiple domains, ensure both the Google tag and tawk.to widget load correctly across all pages.
Related guides
If you have feedback about this article, or if you need more help:
Click the green live chat icon
Schedule a call with us
Visit our community
