【发布时间】:2019-11-25 07:55:24
【问题描述】:
我正在尝试使用 python google-api-client 提取 Google 分析数据。但我需要在请求正文中提及维度和指标列表 'dimensions':[{'name' : 'ga:date'}]。但是有没有办法获得与视图 ID 关联的维度和指标的完整列表。我可以通过 API 调用获取该列表吗?
sample_request = {
'viewId': 'xxxxxx',
'dateRanges': [{'startDate': '7daysAgo', 'endDate': 'today'}],
'metrics' : [{'expression' : 'ga:users'}],
'dimensions':[{'name' : 'ga:date'}]
}
response = api_client.reports().batchGet(
body={
'reportRequests': sample_request
}).execute()
【问题讨论】:
标签: python google-analytics google-api-client google-reporting-api