队列列出维度和指标 here .然而,当我尝试使用 API 查询它时(例如使用 Query Explorer )会发生错误 400。
我试过的查询之一是:metrics = ga:cohortActiveUsers
和 dimensions = ga:cohortNthDay
.
是否可以查询队列分析 通过 API 报告?
最佳答案
您遇到的问题是因为 Query explorer使用 Google Analytics API 的 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"}
}]
}
}]
}
关于google-analytics - 遗传算法 : How to access Cohort Analysis via Analytics API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36477520/