Home / All Integrations / Google Analytics

Connect Google Analytics to your chatbot

Send events to Google Analytics


In order to use this library, you need to create an account on Google Analytics, then create a "Web" property.

Note that you must trigger a pageview before a transaction in order to GA to show the transaction channel right.


do pageViewParams = {
  "user_id": "df33d143-01a4-4bd9-8571-848a6d73617f",
  "documentPath": "/chatbot",
  "campaignName": "test_campaign",
  "campaignSource": "bot",
  "campaignMedium": "ecommerce",
  "campaignKeyword": "flowA"
do gaPV = Fn("google/analytics", method="newPageView", params=pageViewParams)
do eventParams = {
  "user_id": "df33d143-01a4-4bd9-8571-848a6d73617f",
  "category": "chatbot",
  "action": "add_to_cart",
  "label": "shirt",
  "value": "42"
do gaEvent = Fn("google/analytics", method="sendEvent", params=eventParams)
do transactionParams = {
  "user_id": "df33d143-01a4-4bd9-8571-848a6d73617f",
  "transactionId": "S988",
  "revenue": "25",
  "shippingCost": "9.90",
  "tax": "2",
  "affiliation": "amazon",
  "items": [
      "price": 10,
      "quantity": 2,
      "code": "MI44",
      "name": "My item 44",
      "variation": "green",
    }, {
      "price": 5,
      "quantity": 1,
      "code": "MI42",
      "name": "My item 42",
      "variation": "blue",
do gaTransaction = Fn("google/analytics", method="newTransaction", params=transactionParams)


  • newPageView method: user_id and documentPath must be set.
  • sendEvent method: user_id and label must be set.
  • newTransaction method: user_id, transactionId, revenue and items must be set.

Discover similar integrations:

Amplitude Analytics

Many more integrations are coming!

If you have a cool integration in mind, drop us an email on contact@csml.dev and tell us all about it!

Many of our 43 currently available integrations come directly from your suggestions!

Join the Community
on Slack Slack

Come and learn all about CSML with other chatbot enthusiasts on the Slack CSML Community! ūü§ó