Filipe Ferminiano
Filipe Ferminiano

Reputation: 8791

Unable to get data from Google analytics with rga R library

I'm trying to use rga library but I'm getting this error:

Error in parseJSON(txt) : lexical error: invalid char in json text.
                                       <!DOCTYPE html> <html lang=en> 
                     (right here) ------^

This is my code:

rga.open()
profiles<-ga$getProfiles()
ids<-profiles[1]
data <- ga$getData(ids[1],
                   start.date = "2014-12-01", 
                   end.date = "2014-12-04",  
                   metrics = "ga:sessions",  
                   dimensions = "ga:date",
                   max = 1500,
                   sort="",
                   filters="")

I tested the query in https://ga-dev-tools.appspot.com/explorer/ and it's working

What is wrong with the code?

Upvotes: 1

Views: 182

Answers (2)

MarkeD
MarkeD

Reputation: 2631

I suspect this was due to having a space in your ids[1]

Upvotes: 0

Artem Klevtsov
Artem Klevtsov

Reputation: 9423

The rga package not maintained now. Please try RGA or RGoogleAnalytics from CRAN.

Upvotes: 1

Related Questions