如何从 google 分析中获取新近度
How to get recency from google analytics
我通过 google 分析跟踪我的网络应用程序的访问者,我对 "Recency"(在 "Behaviour" 下找到)感兴趣。如果我登录 Google Analytics,可以很容易地下载包含给定时间段内新近度数据的 CSV 文件,但我想知道是否有办法通过 Google Analytics 获取新近度API 这样我就可以自动生成报告。
首先是一个建议:在 query explorer to get a sense of what the API is capable of. Currently it uses the V3 API but I would recommend starting a new project with Analytics Reporting API V4.
中尝试您的查询
答案:查询 API 维度 ga:sessionCount
.
Analytics Reporting API V4 可以轻松地在所需的 存储桶 中请求 ga:sessionCount
。例如,我想查看在 1、10、100、200 之间访问该站点的用户:
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
{
"reportRequests":
[
{
"viewId": "XXXX",
"metrics": [
{"expression": "ga:sessions"},
{"expression": "ga:pageviews"}
],
"dimensions": [
{
"name": "ga:sessionCount",
"histogramBuckets": ["1","10","100","200","400"]
}
],
"orderBys": [
{
"fieldName": "ga:sessionCount",
"orderType": "HISTOGRAM_BUCKET"
}
]
}
]
}
开始使用 API
看看Samples page of the documentation to get an understanding how how the various client libraries frame their requests, and take a stab at one of the quick start guides。如果您遇到困难或有疑问,请返回此处。
我通过 google 分析跟踪我的网络应用程序的访问者,我对 "Recency"(在 "Behaviour" 下找到)感兴趣。如果我登录 Google Analytics,可以很容易地下载包含给定时间段内新近度数据的 CSV 文件,但我想知道是否有办法通过 Google Analytics 获取新近度API 这样我就可以自动生成报告。
首先是一个建议:在 query explorer to get a sense of what the API is capable of. Currently it uses the V3 API but I would recommend starting a new project with Analytics Reporting API V4.
中尝试您的查询答案:查询 API 维度 ga:sessionCount
.
Analytics Reporting API V4 可以轻松地在所需的 存储桶 中请求 ga:sessionCount
。例如,我想查看在 1、10、100、200 之间访问该站点的用户:
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
{
"reportRequests":
[
{
"viewId": "XXXX",
"metrics": [
{"expression": "ga:sessions"},
{"expression": "ga:pageviews"}
],
"dimensions": [
{
"name": "ga:sessionCount",
"histogramBuckets": ["1","10","100","200","400"]
}
],
"orderBys": [
{
"fieldName": "ga:sessionCount",
"orderType": "HISTOGRAM_BUCKET"
}
]
}
]
}
开始使用 API
看看Samples page of the documentation to get an understanding how how the various client libraries frame their requests, and take a stab at one of the quick start guides。如果您遇到困难或有疑问,请返回此处。