How do I track API calls on my ruby ​​in a rails app using google analytics?

I have created an API for external applications to login or make specific web calls using OAuth. I am looking for a way to keep track of the number of times these API calls are used.

Do I have an option?

+3


source to share


2 answers


You can send events using a 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"})

      

+5


source


I believe you can do this in Google Events:

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



There are various Ruby libraries for interacting with GA.

-1


source







All Articles