无法通过googleAnalyticsR

时间:2019-09-06 10:21:01

标签: r google-analytics google-analytics-api

我正在使用该库导出超过6个月的数据。

我在界面中导出的总行数约为2000行。

通过软件包复制报告时,我系统地得到1000行。

是否可以导出总行数?

我的代码看起来很简单-

library(googleAnalyticsR)
my_id <- 123456
ga_auth()

df_ga <- google_analytics(my_id, 
                       date_range = c("2018-12-04", "2019-09-04"),
                       metrics = c("sessions"),
                       dimensions = c("transactionId","sourceMedium","deviceCategory",'region',"city","hour","channelGrouping","userType") ) 

1 个答案:

答案 0 :(得分:2)

您需要添加Max rows才能请求其他行。

# 1000 rows only
thousand <- google_analytics(ga_id, 
                             date_range = c("2017-01-01", "2017-03-01"), 
                             metrics = "sessions", 
                             dimensions = "date")

# 2000 rows
twothousand <- google_analytics(ga_id, 
                             date_range = c("2017-01-01", "2017-03-01"), 
                             metrics = "sessions", 
                             dimensions = "date",
                             max = 2000)  

# All rows
alldata <- google_analytics(ga_id, 
                             date_range = c("2017-01-01", "2017-03-01"), 
                             metrics = "sessions", 
                             dimensions = "date",
                             max = -1)