RGoogleAnalytics: Multiple filters

时间:2016-04-18 10:44:14

标签: r filtering google-analytics-api

I am trying to use multiple filters in RGoogleAnalytics packages, but they doesn't work the same way, as they do in Query Explorer.

I want to get results for Source Medium ga:sourceMedium == google / cpc and for nonbrand kewyords, so at the same time use filter ga:keyword!@Peli

My code is:

Init(start.date = "2016-01-01",
     end.date = "2016-03-31",
     dimensions = c("ga:yearMonth"),
     metrics = c("ga:users", "ga:sessions", "ga:costPerConversion", "ga:ItemQuantity", "ga:transactionShipping", "ga:adCost"),
     table.id = "ga:183149",
     filters = c("ga:keyword!@"brandname";ga:sourceMedium==google / cpc"),
     max.results = 9000)

Based on the API Info, this should do the work. And it does in the query explorer.

When I copy&paste it to R this way, returned results is 0. When I change ; for , it returns the OR statement - summary for all transactions which are google CPC or doesn't contain brandname as keyword.

How can I adjust the filter code, to make it work the same way as it does in query explorer? So it will give me results for nonbrand adwords transactions?

Thanks!

1 个答案:

答案 0 :(得分:0)

我今天遇到了同样的问题。找到了解决方案。对include / exclude和exact / regex进行了测试。

将其翻译成您的用例 -

Init(start.date = "2016-01-01",
     end.date = "2016-03-31",
     dimensions = c("ga:yearMonth"),
     metrics = c("ga:users", "ga:sessions", "ga:costPerConversion", "ga:ItemQuantity", "ga:transactionShipping", "ga:adCost"),
     table.id = "ga:183149",
     filters = c("ga:keyword!@brandname;ga:sourceMedium==google%20/%20cpc"),
     max.results = 9000)

此外,问题是11个月大。您可以使用您发现的任何其他修复来恢复帮助他人。