Google Tag Manager Integration

Learn how to set up Google Tag Manager to track user interactions and behaviors within your Chatbot using GA4

Setting up Google Tag Manager (GTM) for Google Analytics 4 (GA4) event routing for Botsonic Events involves configuring GTM to send specific events generated by Botsonic to your GA4 property. This integration allows you to track user interactions and behaviors within your chatbot using GA4.

Before you begin

  1. Google Tag Manager (GTM) Container Setup: Ensure that you have already set up a GTM container and have access to its ID. This container will be used to manage and deploy tags for tracking Botsonic Events in Google Analytics 4 (GA4).
  2. GTM Installed on Your Website: Verify that GTM is properly installed on your website. This involves adding the GTM container snippet to all pages of your website to enable tracking and tag management.

Step 1 - Set up the Data Layer Variable

Visit https://tagmanager.google.com/#/home and select the Container you've installed on your website which will be used for event tracking and routing.

  1. In the [Variables] page, click [New] to create a new variable.
  2. Then click the [edit] icon to configure the variable, then select the [Data Layer Variable]

  1. Give the Data Layer variable a name. The name should be the same on the variable title space and the Data Layer variable field.
  2. Click [Save]


Step 2 - Set up Triggers

  1. In the [Triggers] page, click [New] to create a new trigger.

  2. Click the [edit] icon to configure the trigger, then select [Custom Event]. We currently support the following triggers:

    • Messenger Closed
    • Messenger Opened
    • Message Sent
    • Starter Question Clicked


  1. The trigger title name must match the event name field, and should fire on [All Custom Events]
  2. Click [Save]

Step 3 - Set up Tags

  1. In the [Tags] page, click [New] to create a new tag.
  2. Click the [edit] icon to configure the tag, then select [Google Tag]

  1. Setup the following, then click [Save]

    • Measurement ID and Event name

    • On the [Configuration] settings section, add the parameters that was created in the first step:

      • send_page_view; value: true

      • {{messenger_closed}}; value: {{messenger_closed}}

    • Add all the triggers that were created in the previous step