Google Analytics Feeds

Allows access to google analytics feeds from ruby.

Does not support any of the OAuth-related authentication methods.

Installation

gem install google_analytics_feeds

Usage

require 'google_analytics_feeds'

# Define your report. Reports are built up like an ActiveRecord or 
# Sequel::Dataset query.
report = GoogleAnalyticsFeeds::DataFeed.new.
  profile(123456).
  dimensions(:visitor_type).
  metrics(:visits)

# Create a session and login. You can optionally pass a
# Faraday::Connection to +new+ to use a different adapter, deal 
# with proxies etc.
session = GoogleAnalyticsFeeds::Session.new
session.("username", "password")

# Fetch a report. Rows are handled with a 
# GoogleAnalyticsFeed::RowHandler - this may just be an anonymous
# block as demonstrated here.
session.fetch_report(report) do
  def row(r)
    puts r.inspect # => outputs the row as a hash.
  end
end

TODO

  • Tests, documentation

  • Filters

  • Access to the management data feed.

  • Auto-follow of paginated result sets.

Versioning

Patch-level releases will not change the API. Minor releases may make breaking changes to the API until a 1.0 release.

Contributing to google_analytics_feeds

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2012 Roland Swingler. See LICENSE.txt for further details.