1
votes

I'm using RGoogleAnalytics and trying to output Custom Dimension using Google APIs. Google announced that "Developers can use custom dimensions to send unique IDs into Google Analytics, and then use the core reporting API to retrieve these IDs along with other Google Analytics data."

My query is like this :

library("RGoogleAnalytics")
client.id <- "xxx....apps.googleusercontent.com"
client.secret <- "xxx..IoG"
token <- Auth(client.id,client.secret)
save(token,file="./token_file")

query.list <- Init(start.date = "2014-12-01",
                   end.date = "2014-12-01",
                   dimensions = "ga:dimension1==UserID",
                   metrics = "ga:sessions ",
                   max.results = 10000,
                   sort = "- ga:dimension1",
                   table.id = "ga:xxxxx58")

ga.query <- QueryBuilder(query.list)
ga.data <- GetReportData(ga.query, token)

and this produces the error : code : 400 Reason : Invalid dimension or metric: ga:dimension1==UserID.

UserID is one of the custom dimension and I can view the list of UserID from the Custom Report. My goal is to get the list of UserID using RGoogleAnalytics. However, I'm not sure what value I need to pass in the code to query custom dimension, (or whether this is even possible using RGoogleAnalytics.)

1
you request dimensions. if you want to filter add an == you have to add a filter.DaImTo
@DalmTo, thanks for the note but sorry I'm not sure I'm not following.So I don't need ==, since I'm not adding filter, but what value I need to pass to output custom dimension?user1486507
ga:dimension1 is what you request to get your first custom dimensionDaImTo
Thank you so much!! it works like a charm =)user1486507

1 Answers

3
votes

You use custom dimensions like other dimensions all you need is ga:dimension1 it will request your first custom dimension. ga:dimension2 would be the second...

You don't need the == you have