Setup
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.
Examples
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)
Parameters
newPageView
method:user_id
anddocumentPath
must be set.sendEvent
method:user_id
andlabel
must be set.newTransaction
method:user_id
,transactionId
,revenue
anditems
must be set.
Usage
App("google/analytics", method="newPageView", params=pageViewParams)
App("google/analytics", method="sendEvent", params=eventParams)
App("google/analytics", method="newTransaction", params=transactionParams)