In this article, we'll explain how to make your Certainly bot send custom defined events to Google Analytics.
Below, we'll cover:
- Defining custom events in your chatbot
- Verifying that custom events are sent to Google Analytics
- Next steps
You'll need to have installed the Certainly extension for Google Analytics and verified that your property is receiving events from Certainly. You can read about how to do both in our article on integrating Certainly with Google Analytics.
Defining custom events in your chatbot
When you install the Certainly extension for Google Analytics, a number of standard events are provided by default.
Custom events can be defined by setting the variable "ga_event" with the value you want to send as an event to Google Analytics. The following example triggers the custom event "faq_order_tracking" every time a chat visitor asks about tracking their shipment:
Make sure you save and publish your changes, otherwise the custom events you have defined will not work in production conversations.
Also, note that the custom event is triggered whenever your Certainly bot lands on the next module in the flow. In the example above, the event is triggered as soon as the chatbot lands on the "Track Order (804665)" Module.
It is not possible to send multiple events at the same time. If you define multiple custom events in parallel, Certainly will only forward the last defined one to Google Analytics.
Verifying that Custom Events are sent to Google Analytics
After you've defined your own custom events and saved and published your changes, you can test them out. Navigate to your website, where you've deployed your Certainly chatbot and installed the Certainly extension for Google Analytics.
Then, simply have a conversation with your chatbot and go through the conversational flow that triggers your custom event(s). Behind the scenes, the event(s) should be triggered.
In the example below, we trigger the chatbot to answer a question about the order shipment status:
The next step is to verify that the custom event has been received by Google Analytics. The process differs depending on whether your business is running on Google Analitycs 4 or Universal Analytics.
Verifying that Custom Events are sent to Google Analytics 4
If you're running on Google Analytics 4, navigate to Reports > Realtime. You should be able to see a list of recently triggered events on your application. The events should include your custom event(s), prefixed by "certainly_".
Verifying that Custom Events are sent to Universal Analytics
If you're running on Universal Analytics, navigate to Realtime > Events. You should be able to see a list of recently triggered events on your application. The events should include your custom event(s), prefixed by "certainly_".
Now that your chatbot is correctly sending both standard and custom events to your Google Analytics dashboard, you can use them to define user segments. Learn how in our article on Using Certainly events in Google Analytics Reports.
Need help? Don't hesitate to reach out to our Customer Success team.