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 click Admin (gear icon in the bottom left).

2. Under Property settings in the left panel, click Data streams (under Data collection).

3. Under Choose a platform, click Web.

4. On the Set up data stream page, enter your website's URL and Stream name. Then, click Create & continue.

5. On the Set up a Google tag page, select Install manually and copy the Google tag (gtag.js) code provided.

6. Paste the tag inside the <head> section of every page where you want to track chat activity.

The Google tag provides the global gtag() function, which you’ll use to send tawk.to events to Google Analytics.

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:

Was this article helpful?

68 out of 112 liked this article

Still need help? Message Us