Send google analytics event in ruby -
i have following code google analytics real time, in ruby:
# execute query sa_visitcount = client.execute(:api_method => analytics.data.realtime.get, :parameters => { 'ids' => "ga:" + saprofileid, 'metrics' => "ga:activevisitors", })
followed with: send_event('sa_realtimevisitors', current: sa_visitcount.data.rows)
this works great , returns active visitor count. trying change return event have created on google analytics. here event looks like. find under real-time , events. trying use event category "ad" listed #2 in screenshot.
the code using attempt in ruby follows.
phonehub_visitcount = client.execute(:api_method => analytics.data.realtime.get, :parameters => { 'ids' => "ga:" + saprofileid, 'metrics' => "ga:sessionswithevent", })
followed with:
send_event('phonehub_event', current: phonehub_visitcount.data.rows)
this returns nothing. i'm still using original ga id, i'm trying tell @ event created. there way in ruby make ga realtime return results event? ideally solution i'm looking return real time active visitors on event have made.
after further research found had specify v3 in api method.
so instead of phonehub_visitcount = client.execute(:api_method => analytics.data.realtime.get, :parameters => {
i had use api_method = client.discovered_api('analytics','v3').data.ga.get
add phonehub_visitcount = client.execute(:api_method => api_method, :parameters => {
Comments
Post a Comment