Integrate the Codemonkey Web SDK with Google Analytics

In this article, we'll explain how to make your Codemonkey bot send data to Google Analytics, and how to visualize Codemonkey data in your Google Analytics dashboard.


The integration requires the use of a lightweight extension for the Codemonkey Widget. Please note that it is not possible to use this extension when Codemonkey is deployed in a different channel, such as Zendesk Chat or Facebook Messenger.

Below, we will cover:


  1. You have created a chatbot on the Codemonkey Platform.
  2. You own an account on Google Analytics with at least one registered property (check out Google's documentation).
  3. You have included Google Analytics's JavaScript library (analytics.js) on your website (check  out Google's documentation).

Configuring the Codemonkey Extension

  1. Embed the Codemonkey Widget on your website after your Google Analytics snippet. Read about where you can grab the snippet for the Codemonkey Widget.

  2. Embed the Codemonkey Google Analytics extension right after the Codemonkey Widget. This is the snippet, hosted by Codemonkey's CDN: 
    <script src=""></script>

    After you finish steps 1 and 2, your webpage should look similar to this:

  3. Navigate to your chatbot on the Codemonkey Platform. Make sure your bot is set up to expose Custom Variables to the hosting website.

  4. Then, add the events you want to send to Google Analytics by setting up the Custom Variable "ga_event" inside relevant Modules. For example, the following setup will throw a "certainly_chat_started" event each time the visitor goes past the <md>Starting module:

  5. The variable "ga_event" controls the event action that will be sent to your Google Analytics dashboard. As a best practice, we recommend that you stick to snake_case as a naming convention, and that you prepend "certainly_" to the actual event name. For example, if you want to send an event for "FAQ Shipping", we recommend you configure the event as "certainly_faq_shipping".

    You can also set up a custom event to be sent to Google Analytics in the Global Connections of your bot:


  • You can define as many events as you want, but you can only define one event per Module. If you need to send multiple events at once, please split them across multiple consecutive Modules.
  • Each event you define will be sent to Google Analytics as soon as your chatbot moves to the next Module in the conversation. If the bot does not move to a new Module, the event is never sent to Google Analytics.
  • Event categories and labels are no longer supported by Google Analytics, as of GA4. If your dashboard is running on a previous version, the event will automatically appear under the category "certainly".

That's ityou've now set up your Google Analytics event. Don't forget to save and publish your bot!


Configuring your Google Analytics (Universal) Dashboard

Note: If you're running on Google Analytics (v4), please refer to the following section.

Your chatbot is now sending events to your Google Analytics property. In order to visualize that data on your Analytics dashboard, you will need to set up some user segments. You can read about how to build custom segments in Google's documentation.

For example, the following custom segment includes all website visitors that had a chat with Codemonkey:mceclip6.png

You can configure multiple user segments based on Codemonkey events. The following custom segment includes all visitors that both (1) had a chat with your Codemonkey chatbot and (2) purchased something from your webshop:

You can then use your Codemonkey segments to visualize data inside Google Analytics' Audience Overview:

Additionally, you can use your Codemonkey segments to visualize data inside Google Analytics' Ecommerce Conversions view:mceclip9.png


Configuring your Google Analytics (v4) Dashboard

Note: If you're running on Google Analytics (Universal), please refer to the previous section.

Your Google Analytics property is now receiving custom events from your Codemonkey bot. It might take up to 24 hours until the events are visible in your dashboard. Once they are, you can use them to create user segments, which provides means of exploring your data.

If you are running on Google Analytics v4, then creating a user segment can be done via the Explorations tool. The following example shows how to create a segment called "Codemonkey - Chat Started", which includes all users linked to an event "certainly_chat_started". The event name reflects the event label you defined in your own chatbot within the Configuring the Codemonkey Extension section above.


You can combine Codemonkey events with other events, custom or built-in, from Google Analytics. For instance, the following user segment, "Codemonkey - Made a Purchase", includes all users who (1) had at least one chat with Codemonkey and (2) had at least one transaction on the webshop.


If you have any questions about Codemonkey's extension for Google Analytics, feel free to get in touch with us!

Was this article helpful?

0 out of 0 found this helpful
Have more questions? Submit a request

Comments (0 comments)

Please sign in to leave a comment.