Google Analytics
Fire events to your Google Analytics account from the chatbot flow.
Google Analytics is an analytics tracking tool built by Google which websites use to track the visitor behaviour.
When you want you track certain events that occur on your website, you need to fire events on Google Analytics.
To fire an event to GA from Hello Moe, all you need to do is define a "Google Analytics" block at the point in the chatbot flow when you want to fire.

Measurement ID
The measurement ID acts as a critical link, connecting your website to the corresponding data stream in Google Analytics 4. It ensures that the data from your site is sent to the right location.
Event name
The name of the event that you want to fire. Event names are to be written in lowercase without spaces and help you easily understand what that event is.
Some examples are -- chat-started, menu-selected, lead-generated etc.
Event parameter
An event parameter is an additional piece of data about a user interaction on a website and/or app, offering valuable context and details about the interaction.
For example, in the below screenshot we have a main menu with multiple options. We can create an event "menu-selected" and pass an additional event parameter which tracks the menu selected under "option".

Learn more about event parameters
You can use variables in the Event name, and while defining value to event parameters
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.
Copy
window.dataLayer = window.dataLayer || [];
function gtag() {
window.dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "YOUR-MEASUREMENT-ID");
gtag("event", "YOUR-EVENT-NAME", {
"send_to": "YOUR-MEASUREMENT-ID"
// ADDITIONAL PARAMETERS THAT YOU MAY WANT TO PASS
});
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 -- https://developers.google.com/analytics/devguides/collection/gtagjs/events
Once fired, you can create a tag on Google Tag Manager that listens to this event as a trigger and triggers its tag, which would fire an event on your GA4 account.
Last updated