我尝试过的一个问题是:metrics = ga:cohortActiveUsers
和dimensions = ga:cohortNthDay
。
是否可以通过API查询群组分析报告?
答案 0 :(得分:1)
答案 1 :(得分:0)
您遇到的问题是因为Query explorer使用了Google AnalyticsAPI的v3。如果您查看Dimensions and Metrics Explorer,您会注意到这些维度已添加到Analytics Reporting API V4中。
您收到的错误消息不正确,应尽快予以纠正。它应该更像This metric cannot be used in Version 3 of the API
。你在我们推出新API的过程中发现了这一点。现已正式发布,请参阅更改log
要使用这些新维度和指标,您必须构建V4 cohort request:
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
{
"reportRequests": [{
"viewId": "XXXX",
# No date range is required in the request
"dimensions": [{"name": "ga:cohort" },{"name": "ga:cohortNthDay" }],
"metrics": [
{"expression": "ga:cohortActiveUsers" },
{"expression": "ga:cohortTotalUsers"}
],
"cohortGroup": {
"cohorts": [{
"name": "cohort 1",
"type": "FIRST_VISIT_DATE",
"dateRange": { "startDate": "2015-08-01", "endDate": "2015-08-01"}
},{
"name": "cohort 2",
"type": "FIRST_VISIT_DATE",
"dateRange": {"startDate": "2015-07-01", "endDate": "2015-07-01"}
}]
}
}]
}