如何使用谷歌分析跟踪ruby on rails应用程序上的API调用?

时间:2022-11-05 15:16:40

I created an API for external applications to log in or make specific web calls using OAuth. What I'm looking for is a way to track the number of times these API calls are being used.

我为外部应用程序创建了一个API,用于使用OAuth登录或进行特定的web调用。我要寻找的是一种跟踪这些API调用被使用的次数的方法。

Is there an option for me?

有我的选择吗?

2 个解决方案

#1


5  

You could send the events with the measurement protocol.

您可以使用度量协议发送事件。

require "net/http"
require "uri"

uri = URI.parse("http://www.google-analytics.com/collect")

Net::HTTP.post_form(uri, {"v" => "1",
                          "tid" => "UA-XXXX-1",
                          "cid" => "555",
                          "t" => "event",
                          "ec" => "API",
                          "ea" => "request",
                          "el" => "data/get",
                          "ev" => "5"})

#2


-1  

I believe you can do this with Google Events:

我相信你可以通过谷歌事件做到这一点:

https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

There are various Ruby libraries for interacting with GA.

有各种Ruby库可以与GA交互。

#1


5  

You could send the events with the measurement protocol.

您可以使用度量协议发送事件。

require "net/http"
require "uri"

uri = URI.parse("http://www.google-analytics.com/collect")

Net::HTTP.post_form(uri, {"v" => "1",
                          "tid" => "UA-XXXX-1",
                          "cid" => "555",
                          "t" => "event",
                          "ec" => "API",
                          "ea" => "request",
                          "el" => "data/get",
                          "ev" => "5"})

#2


-1  

I believe you can do this with Google Events:

我相信你可以通过谷歌事件做到这一点:

https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide

There are various Ruby libraries for interacting with GA.

有各种Ruby库可以与GA交互。