We are measuring site conversions with Google Analytics.
I used the Google Analytics API
to automatically get conversions and revenue values.
python
response = analytics.reports().batchGet(
body={
'reportRequests': [
{ 'viewId': view_id,
'dateRanges': [{'startDate': start_date, 'endDate': end_date}],
'metrics': [{'expression': 'ga:transactions'}, {'expression': 'ga:transactionRevenue'}]
}]
}
).execute()
values = response.get['reports'][0]['data']['totals'][0]['values']
transactions = values[0]
transactionRevenue = values[1]
I searched for metrics in the reference manual.
I used slack web
.
slack = slackweb.Slack(url=slack_webhook_url))
slack.notify(text=text)
It's easy.
For the first time, there are lots of things other than code, knowledge about creating Google service account keys, knowledge of Google Analytics configuration and user management, key type P12 or JSON, Slack webhook settings, etc. I hope you have time to spare. By comparison, the code is less difficult.
Dimensions & Metrics Explorer | Analytics Reporting API v4 | Google Developers https://developers.google.com/analytics/devguides/reporting/core/dimsmets
Collect Google Analytics data via Python | Developers.IO * http://dev.classmethod.jp/business/business-analytics/getting-google-analytics-data-via-python/
POST a message from python to Slack via incoming webhook * http://qiita.com/satoshi03/items/14495bf431b1932cb90b
Recommended Posts