How to set up tawk.to for Google Analytics 4 tracking with Google Tag Manager

You can track chat activity from your tawk.to widget inside Google Analytics 4 (GA4) by sending events through Google Tag Manager (GTM).

This guide walks you through the full setup — from configuring GA4 in GTM to tracking chat events and marking them as conversions.

Before you start

Ensure you have:

  • The tawk.to chat widget installed on your website
  • A Google Analytics account and GA4 property
  • A Google Analytics data stream
  • A tag for the tawk.to widget in Google Tag Manager

If you haven’t added the tawk.to widget through GTM yet, follow the steps in this guide first:
How to add the tawk.to widget with Google Tag Manager

To learn more about setting up tawk.to for Google Analytics tracking, see this guide:
How to set up tawk.to for Google Analytics tracking

Set up your Google Analytics configuration in GTM

Follow these steps to configure GA4 inside Google Tag Manager.

1. Log in to Google Tag Manager.

2. Select your container.

3. Click Tags in the left menu.

4. Click New.

5. Enter the tag name and click Tag Configuration.

6. Click Google Analytics.

7. Choose Google Analytics: GA4 Configuration.

8. Enter your Measurement ID (found in GA4 under AdminData Streams).

9. Click Triggering.

10. Select All Pages.

11. Click Save.

This tag loads Google Analytics on every page and allows event tracking to work properly.

Creating custom events for Google Analytics

You can configure tawk.to to send chat events into GTM’s dataLayer. tawk.to provides a JavaScript API that allows you to detect chat activity. You can learn more about it here: JavaScript API

Add a Custom HTML Tag in GTM

1. In Google Tag Manager, go to Tags.

2. Click New.

3. Click Tag Configuration.

4. Select Custom HTML.

5. Paste the following code in the HTML field:

What this does:
  • Waits for the tawk.to widget to load
  • Detects when a chat starts
  • Pushes a custom event (tawk_chat_started) into GTM

6. Click Triggering.

7. Select All Pages.

8. Click Save.

You can repeat this process for other events such as chat ended or offline messages submitted by using the appropriate JavaScript API methods.

Creating a custom event trigger in GTM

Now, you can tell GTM to listen for the event you just created.

1. Click Triggers in the left menu.

2. Click New.

3. Enter the trigger name and click Trigger Configuration.

4. Select Custom Event.

5. Enter this event name exactly:

tawk_chat_started

6. Under This trigger fires on, choose All Custom Events.


7. Click Save.
Note:
  • Event names are case-sensitive. Ensure the event name matches exactly.
  • Event names must not contain spaces. Use underscores instead.

Create a GA4 event tag

Next, you can create the tag that sends the event to Google Analytics.

  1. Go to Tags.

  2. Click New.

  3. Click Tag Configuration.

  4. Select Google Analytics: GA4 Event.

  5. Under Tag Configuration, select the GA4 Configuration tag you created earlier.

  6. In Event Name, enter: chat_started

  7. Click Triggering.

  8. Select the Custom Event trigger you created.

  9. Click Save.


This connects your tawk.to chat event to Google Analytics.

Check if the GA event tag has been triggered

Before publishing your changes, test everything:

1. Click Preview in Google Tag Manager.

2. Enter your website’s URL and click Connect.

3.Start a chat on your tawk.to widget.

4. Confirm that:

- The tawk_chat_started event appears in Preview mode.
- The GA4 Event tag fires successfully.

5. If everything looks correct, click Submit.

6. Click Publish.

Verify the event in Google Analytics 4

1. Log in to Google Analytics and select your GA4 property.

2. Click Reports.

3. Select Realtime overview. You can also select User engagement & retentionEvents.

4. Start a new chat on your website.

5. You should see the chat_started event appear.

Keep in mind:
  • Realtime reports update within seconds.
  • Standard reports may take up to 24 hours.

Mark the custom event as a key event

You can mark your custom event as a key event if it’s an important goal for your business.

1. In GA4, go to Admin.

2. Go to Data display > Events.

3. Locate your custom event and click the star icon (under Key events).

Once enabled, GA4 will track chat starts as conversions in your reports.

Additional considerations

  • Make sure the tawk.to widget loads before the custom script runs.


  • Check your browser console for JavaScript errors if the event does not trigger.

In case you encounter any issues, our support team is always available. Schedule a call so we can better assist you.

References

Related guides


If you have feedback about this article, or if you need more help:
 

Was this article helpful?

52 out of 78 liked this article

Still need help? Message Us