R Google Analytics Premium

时间:2018-05-28 07:01:34

标签: r google-analytics

我在R version 1.1.442中运行此代码时没有任何错误,但在新版本1.1.453中,此代码会抛出多个错误,例如Error in initerror in get report data。新版本library(RGoogleAnalytics)也被RGoogleAnalyticsPremium

取代
library(RGoogleAnalytics)
library(RGA)
library(RCurl)
client.id="xxxxxxxx-ts4sbtvss5bm1dv6864i8jtkng4tqmtp.apps.googleusercontent.com"
client.secret="xxxxxxx"

token<-Auth(client.id,client.secret)
save(token,file="./token_file")
ValidateToken(token)

query.list <- Init(start.date = "2018-05-01",
                   end.date = "2018-05-05",
                   dimensions = c("ga:dimension32","ga:sourcemedium","ga:eventCategory","ga:eventAction"),
                   metrics = c("ga:sessions","ga:goal6Completions","ga:users"),
                   max.results = 20000,
                   sort = "ga:sessions",
                   filters=c("ga:sourcemedium=~organic;ga:eventCategory=~page_navigation,ga:eventAction=~submitted_crf"),
                   table.id = "ga:169730504")  
ga.query <- QueryBuilder(query.list)

ga.data <- GetReportData(ga.query, token,paginate_query = T)

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

新库中没有 max.results = 20000 table.id =“ ga:169730504” ,删除它们后应该可以使用。然后使用GetFile而不是GetReportData。我还没有成功获得这些数据,如果成功,请与我分享您的代码。