I'm trying to pull the number of times a certain event (by the event-action) fired with the Google Analytics v4 Javascript API. What do I need to put in the filter section to get the number that I'm looking for? This is what I have now and it's just returning zero:
我试图通过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"]
}
]
}
],
}]
1 个解决方案
#1
0
Your request appears to be correct:
您的请求似乎是正确的:
{
"reportRequests":
[
{
"viewId": "XXXX",
"dimensions":
[
{
"name": "ga:eventLabel"
}
],
"metrics":
[
{
"expression": "ga:totalEvents"
}
],
"dimensionFilterClauses":
[
{
"filters":
[
{
"operator": "EXACT",
"dimensionName": "ga:eventLabel",
"expressions": ["name-of-label"]
}
]
}
]
}
]
}
Ruling everything out I would suggest making the request without the filter to ensure that you have the full string name-of-label
. If you only have a partial string then use a different operator:
排除所有内容我会建议在没有过滤器的情况下发出请求,以确保您拥有完整的字符串名称标签。如果您只有部分字符串,则使用其他运算符:
-
BEGINS_WITH
Matches the values which begin with the match expression provided. -
ENDS_WITH
Matches the values which end with the match expression provided. -
PARTIAL
Substring match. - ...
BEGINS_WITH匹配以提供的匹配表达式开头的值。
ENDS_WITH匹配以提供的匹配表达式结尾的值。
PARTIAL子串匹配。
#1
0
Your request appears to be correct:
您的请求似乎是正确的:
{
"reportRequests":
[
{
"viewId": "XXXX",
"dimensions":
[
{
"name": "ga:eventLabel"
}
],
"metrics":
[
{
"expression": "ga:totalEvents"
}
],
"dimensionFilterClauses":
[
{
"filters":
[
{
"operator": "EXACT",
"dimensionName": "ga:eventLabel",
"expressions": ["name-of-label"]
}
]
}
]
}
]
}
Ruling everything out I would suggest making the request without the filter to ensure that you have the full string name-of-label
. If you only have a partial string then use a different operator:
排除所有内容我会建议在没有过滤器的情况下发出请求,以确保您拥有完整的字符串名称标签。如果您只有部分字符串,则使用其他运算符:
-
BEGINS_WITH
Matches the values which begin with the match expression provided. -
ENDS_WITH
Matches the values which end with the match expression provided. -
PARTIAL
Substring match. - ...
BEGINS_WITH匹配以提供的匹配表达式开头的值。
ENDS_WITH匹配以提供的匹配表达式结尾的值。
PARTIAL子串匹配。