Using Javascript

Overview on how to fire events on Google Analytics using the Javascript action block.

Step 1: Make sure that the Google Analytics 4 code snippet is present

In order to fire events to your measurement ID, you need to first make sure that the Google Analytics code snippet is already added to your website. Usually, website either add it manually on the code or using Google Tag Manager.

Step 2: Add the Javascript block on the chatbot flow

At the point in the chatbot flow when you want to fire an event, add the Javascript action block and input this code.

window.dataLayer = window.dataLayer || [];
function gtag() {
gtag("js", new Date());
gtag("config", "YOUR-MEASUREMENT-ID");
gtag("event", "YOUR-EVENT-NAME", {
  "send_to": "YOUR-MEASUREMENT-ID"

Make sure you add the MEASUREMENT ID of your GA4 property in the mentioned places. And also, use the event name as per your requirement.

You can find your MEASUREMENT ID by navigating to the Settings -> Data collection -> Data streams

Refer to this page for default GA events --

Note that it takes about 20-30 seconds for events to reflect in Google Analytics

Last updated