为什么我在 R 中 'Error code : 400 Reason : Invalid value' 在 GA Reporting Core API 上创建序列?

Why I am getting 'Error code : 400 Reason : Invalid value' creating sequences on GA Reporting Core API in R?

我正在尝试使用 RGoogleAnalytics 包通过 R 中的 Reporting Core API V3 获取 Google Analytics 的数据。

我想获取在两个不同的特定页面路径中按顺序排列的用户。为此,我正在使用正则表达式:

filters_pre = paste0('ga:dimension15==',server_ab_test,';ga:hostname==',site_type)

filters_pre_category=paste0(filters_pre,';ga:users::sequence::ga:pagePath=~(^/$);->>ga:pagePath=~(^/eyeglasses-collection)')

query.init <- Init(start.date = start_date,
                     end.date = end_date,
                     dimensions = "ga:date,ga:dimension15",
                     metrics = "ga:sessions,ga:users,ga:pageviews",
                     filters = as.character(filters_pre_category),
                     max.results = 10000,
                     sort = '-ga:date',
                     table.id = 'ga:XXXXXXXXXX')

query <- QueryBuilder(query.init) 
dt_aux <- GetReportData(query, token, split_daywise = T,delay = 5) 

结果我得到

Error in ParseDataFeedJSON(GA.Data) : 
  code : 400 Reason : Invalid value 'ga:dimension15==react cart turned on;ga:hostname==www.test1.com;ga:users::sequence::ga:pagePath=~(^/$);->>ga:pagePath=~(^/eyeglasses-collection)' for filters parameter.

有人知道如何使用序列来过滤结果吗?

您的过滤器 (Invalid value [...] for filters parameter) 似乎有问题,它包含分段条件 (ga:users::sequence) :

https://developers.google.com/analytics/devguides/reporting/core/v3/segments#sequences

因此,要么将您的细分条件移至细分参数,要么将其删除,但不要在您的过滤器中包含细分条件:

https://developers.google.com/analytics/devguides/reporting/core/v3/reference#filters