Having trouble with realtime
Closed this issue · 19 comments
I have access to the realtime API (already requested it).
When I try to access it however, legato just errors.
If I try this:
rt_query = Data.realtime
data = rt_query.map {|item| item}
I get an error about user being nil, to fix that I had to do this:
rt_query.profile = profile
If I try any of the following:
rt_query = Data.realtime
rt_query.profile = profile
data = rt_query.map {|item| item}
data= Data.results(profile).realtime.map {|item| item}
data = Data.page_title($config['model']['title_filter'],profile).realtime.map {|item| item }
I get an error about "message"=>"Required parameter: metrics"
which makes no sense becuase accourding to this, google analytics realtime has no metrics, still I try supplying them (in the model of course)and I get errors that the metrics don't exists (no suprise) and all the metrics in the message are pre-fixed with ga:
.
I've followed the help doc, what am I doing wrong?
What does your Data
class look like?
Metrics are the numeric values, so it has to have some metric. I think that page just has terrible styling. If you look at the page tracking doc, it shows pageviews as a metric:
It looks like this:
class Data
extend ::Legato::Model
filter :page_title, &lambda {|title| matches(:page_title,title)}
# metrics *$config['model_realtime']['metrics'].map(&:to_sym)
dimensions *$config['model_realtime']['dimensions'].map(&:to_sym)
end
Have you tried with metrics? Try pageviews
, just to see what happens.
I just get this error response:
{"errors"=>[{"domain"=>"global", "reason"=>"badRequest", "message"=>"No such dimension(s): ga:activeUsers\nNo such metric(s): ga:pageview"}], "code"=>400, "message"=>"No such dimension(s): ga:activeUsers\nNo such metric(s): ga:pageview"}: (OAuth2::Error)
{"error":{"errors":[{"domain":"global","reason":"badRequest","message":"No such dimension(s): ga:activeUsers\nNo such metric(s): ga:pageview"}],"code":400,"message":"No such dimension(s): ga:activeUsers\nNo such metric(s): ga:pageview"}}
https://developers.google.com/analytics/devguides/reporting/realtime/dimsmets/user activeUsers
is a metric …
Also, it's pageviews
, plural for the metric.
{"errors"=>[{"domain"=>"global", "reason"=>"badRequest", "message"=>"Unknown metric(s): ga:pageviews, ga:activeUsers"}], "code"=>400, "message"=>"Unknown metric(s): ga:pageviews, ga:activeUsers"}: (OAuth2::Error)
{"error":{"errors":[{"domain":"global","reason":"badRequest","message":"Unknown metric(s): ga:pageviews, ga:activeUsers"}],"code":400,"message":"Unknown metric(s): ga:pageviews, ga:activeUsers"}}
Same response.
I think that legato is trying to pull from google analytics rather then real time, I don't know why though.
Yes, it should be rt:pageviews
. I need to know what you're specifically running to get that error.
what do you mean specifically running?
You gave multiple examples of code in the original issue comment … which are you running now?
currently just:
data = rt_query.map {|item| item}
What does:
puts rt_query.realtime?
puts rt_query.tracking_scope
Output?
Which version of Legato?
They both output as expected:
true
rt
version 0.4.0
.
I wonder, perhaps they (google) haven't authorised the API like I thought they were supposed to have?
This is due to some missing documentation. Rather than fixing that, I'm going to make Legato not require setting the tracking_scope
option on metrics/dimensions. Gimme a few and I'll cut a new gem.
I helped?
Any way, I'm a little confused, what do you mean?
I'm just making it work :-)
If you need this to be fixed right now … pass a hash to metrics or dimenions with {tracking_scope: 'rt'}
as the last value. This will break when I release the next version of the gem in a few minutes.
Please try newly released v0.5.0.
I will, and thanks, and again, sorry for being rude, it really wasn't my intention to be so.