我正在使用Google Analytics的增强型电子商务跟踪功能将JS中的数据发送到GA:
ga("ec:addImpression", {
brand: null,
dimension2: "shop123",
id: 1,
list: "Search",
name: "Product 123",
position: 1
});
ga("send", "pageview");
然后,我使用Reporting API生成一些图表。在这里,我想按自定义维度dimension2
进行过滤。请求如下所示:
{
"reportRequests":[
{
"dateRanges":[
{
"startDate":"2016-10-17",
"endDate":"2016-11-16"
}
],
"viewId":"132093148",
"metrics":[
{
"expression":"ga:productListViews"
}
],
"dimensions":[
{
"name":"ga:date"
},
{
"name":"ga:dimension2"
}
],
"dimensionFilterClauses":[
{
"filters":[
{
"dimension_name":"ga:dimension2",
"operator":"EXACT",
"expressions":[
"shop123"
]
}
]
}
]
}
]
}
但是,这不会返回任何结果:
{
"reports":[
{
"columnHeader":{
"dimensions":[
"ga:date",
"ga:dimension2"
],
"metricHeader":{
"metricHeaderEntries":[
{
"name":"ga:productListViews",
"type":"INTEGER"
}
]
}
},
"data":{
"totals":[
{
"values":[
"0"
]
}
]
}
}
]
}
但当我删除dimensionFilterClauses
时,我会收到所有结果,当然不会被dimension2
过滤。
过滤该维度时有什么问题吗?
答案 0 :(得分:0)
更改dimension_name
的字符dimensionName
并尝试。
正如您在示例中所看到的:https://developers.google.com/analytics/devguides/reporting/core/v4/samples
"dimensionFilter":
{
"dimensionName":"ga:browser",
"operator":"EXACT",
"expressions":["Safari"]
}