在 ruby 中发送 google 分析事件
Send google analytics event in ruby
我有以下 google 实时分析代码,在 ruby:
# Execute the query
sa_visitCount = client.execute(:api_method => analytics.data.realtime.get, :parameters => {
'ids' => "ga:" + saprofileID,
'metrics' => "ga:activeVisitors",
})
随后是:
send_event('sa_realtimevisitors', current: sa_visitCount.data.rows)
效果很好,而且 return 是一个活跃的访客数。
现在我正在尝试将其更改为 return 我在 google 分析上创建的事件。这是事件的样子。您可以在实时和事件下找到它。我正在尝试使用事件类别 "Ad" 在屏幕截图中列为 #2。
我在 ruby 中尝试使用的代码如下。
phonehub_visitCount = client.execute(:api_method => analytics.data.realtime.get, :parameters => {
'ids' => "ga:" + saprofileID,
'metrics' => "ga:sessionsWithEvent",
})
后跟:
send_event('phonehub_event', current: phonehub_visitCount.data.rows)
这个return没什么。我仍在使用原来的 GA ID,但我试图告诉它查看我创建的事件。 ruby 中是否有办法使 GA 实时 return 事件结果?理想情况下,我正在寻找的解决方案是 return 实时活跃访问者参与我举办的活动。
经过进一步研究,我发现我必须在 api 方法中指定 v3。
所以 phonehub_visitCount = client.execute(:api_method => analytics.data.realtime.get, :parameters => {
我不得不使用
api_method = client.discovered_api('analytics','v3').data.ga.get
然后加
phonehub_visitCount = client.execute(:api_method => api_method, :parameters => {
我有以下 google 实时分析代码,在 ruby:
# Execute the query
sa_visitCount = client.execute(:api_method => analytics.data.realtime.get, :parameters => {
'ids' => "ga:" + saprofileID,
'metrics' => "ga:activeVisitors",
})
随后是:
send_event('sa_realtimevisitors', current: sa_visitCount.data.rows)
效果很好,而且 return 是一个活跃的访客数。
现在我正在尝试将其更改为 return 我在 google 分析上创建的事件。这是事件的样子。您可以在实时和事件下找到它。我正在尝试使用事件类别 "Ad" 在屏幕截图中列为 #2。
我在 ruby 中尝试使用的代码如下。
phonehub_visitCount = client.execute(:api_method => analytics.data.realtime.get, :parameters => {
'ids' => "ga:" + saprofileID,
'metrics' => "ga:sessionsWithEvent",
})
后跟:
send_event('phonehub_event', current: phonehub_visitCount.data.rows)
这个return没什么。我仍在使用原来的 GA ID,但我试图告诉它查看我创建的事件。 ruby 中是否有办法使 GA 实时 return 事件结果?理想情况下,我正在寻找的解决方案是 return 实时活跃访问者参与我举办的活动。
经过进一步研究,我发现我必须在 api 方法中指定 v3。
所以 phonehub_visitCount = client.execute(:api_method => analytics.data.realtime.get, :parameters => {
我不得不使用
api_method = client.discovered_api('analytics','v3').data.ga.get
然后加
phonehub_visitCount = client.execute(:api_method => api_method, :parameters => {