我试图通过Google Analytics v4 Javascript API提取特定事件(通过事件操作)的次数。我需要在过滤器部分放置什么来获取我正在寻找的数字?这就是我现在所拥有的,它只是返回零:
// Call the Analytics Reporting API V4 batchGet method.
gapi.client.analyticsreporting.reports.batchGet( {
"reportRequests":[
{
"viewId":VIEW_ID,
"dateRanges":[
{
"startDate":"yesterday",
"endDate":"today"
}],
"metrics":[
{
"expression":"ga:totalEvents"
}],
"dimensions": [{"name":"ga:eventLabel"}],
"dimensionFilterClauses": [
{
"filters": [
{
"dimensionName": "ga:eventLabel",
"operator": "EXACT",
"expressions": ["name-of-label"]
}
]
}
],
}]
答案 0 :(得分:0)
您的请求似乎是正确的:
{
"reportRequests":
[
{
"viewId": "XXXX",
"dimensions":
[
{
"name": "ga:eventLabel"
}
],
"metrics":
[
{
"expression": "ga:totalEvents"
}
],
"dimensionFilterClauses":
[
{
"filters":
[
{
"operator": "EXACT",
"dimensionName": "ga:eventLabel",
"expressions": ["name-of-label"]
}
]
}
]
}
]
}
排除所有内容我会建议在没有过滤器的情况下发出请求,以确保您拥有完整的字符串name-of-label
。如果您只有部分字符串,请使用其他operator:
BEGINS_WITH
匹配以匹配表达式开头的值
提供。ENDS_WITH
匹配以匹配结尾的值
提供表达。PARTIAL
子串匹配。