Connecting to Google Analytics API in a Rails App

How to track API calls on my ruby on rails app using google analytics?

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"})

Integrate Google Analytics Dashboard in Rails

It's a Javascript library, so you would create new a view and paste some HTML and JS into it. You'll have to make sure it works with your application layout. The Embed API - Getting Started guide shows the code to get a dashboard up and running.

Google Analytics API and Rails

I just needed to give permission to the 123@developer.gservice... on the

Manage > User Management tab

How can I incorporate Google Analytics results into my Rails 3 app?

Check out the GARB library http://www.viget.com/extend/google-analytics-api-with-ruby-and-garb-making-it-even-easier/

Code from their site:

profile = Garb::Profile.first('UA-XXXXXX-XX')

class Pageviews
extend Garb::Resource
metrics :pageviews
end

# Now get those pageviews!

profile.pageviews


Related Topics



Leave a reply



Submit