Project

ariadna

0.0
No commit activity in last 3 years
No release in over 3 years
Google Analytics A.P.I. V3 wrapper with oauth2
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

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.all

Get a list of all web properties available for an account

  properties = accounts.first.properties.all

Get a list of all profiles available for a web property

  profiles    = properties.first.profiles.all

Create 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])
      .all

All 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
  end

More info

Contributors

License

Released under MIT license