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 = App("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 = App("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 = App("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.


App("google/analytics", method="newPageView", params=pageViewParams)
App("google/analytics", method="sendEvent", params=eventParams)
App("google/analytics", method="newTransaction", params=transactionParams)
Discover similar integrations:
Amplitude Analytics

Join the Community
on Slack Slack

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