Ariadna
Google Analytics API wrapper.
It uses Oauth2 as authorization
Installation
Add this line to your application's Gemfile:
gem 'ariadna'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ariadna
Usage
Create a new connexion with your Oauth2 access token
analytics = Ariadna::Analytics.new(access_token)Get a list of all accounts available
accounts = analytics.accounts.allGet a list of all web properties available for an account
properties = accounts.first.properties.allGet a list of all profiles available for a web property
profiles = properties.first.profiles.allCreate a query with metrics and dimensions
results = profile.results.select(
:metrics => [:visits, :bounces, :timeOnSite],
:dimensions => [:country]
)
.where(
:start_date => Date.today,
:end_date => 2.months.ago,
:browser => "==Firefox"
)
.limit(100)
.offset(40)
.order([:visits, :bounces])
.allAll the metrics and dimensions returned by the query are mapped into attributes.
results.each do |result|
puts result.visits
puts result.bounces
puts result.timeOnSite
puts result.country
endMore info
Contributors
- Jorge Alvarez http://www.alvareznavarro.es