Socket
Book a DemoInstallSign in
Socket

analytics-rb

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-rb

0.0.12
bundlerRubygems
Version published
Maintainers
1
Created
Source

Analytics Build Status Code Climate Gem Version Dependency Status githalytics.com alpha

A Ruby interface to the Google Analytics API.

Installation

Add this line to your application's Gemfile:

gem 'analytics-rb'

And then execute:

$ bundle

Or install it yourself as:

$ gem install analytics-rb

Usage

Authentification

To make calls to the Google Analytics API, you have to authenticate via an API key (which you can get from the Google APIs Console. To set your API key and get started, use:

Analytics.consumer_key    = 'your key'
Analytics.consumer_secret = 'your secret'

Then you have to provide an access token ( OAuth or OAuth2 ) to manage or visualize statistics.

client = Analytics::Client.new(Analytics::OAuth.access_token('my token', 'my secret')) # With OAuth 1.x 
client = Analytics::Client.new(Analytics::OAuth.access_token('my token'))              # With OAuth 2.x 

Management

You can access to the accounts, web properties and profile from an Analytics::Client

client.accounts        # returns an array of Analytics::Account
client.web_properties  # returns an array of Analytics::WebProperty
client.profiles        # returns an array of Analytics::Profile

Reporting

You can access the report object from an Analytics::Profile

profile.report
# or 
Analytics::Report.new('profile_id', access_token) # access_token is a OAuth::AccessToken or  OAuth2::AccessToken

You can grab data with a simple DSL

report.visits(0, Time.now) # it should grab all visits from Jan 1st 1970 to now
# you can provide all metrics from google analytics ( visitors, new_visits, percent_new_visits, ... )
  
# you can provide a metric and a dimension
report.visits_by_month(0, Time.now)

# you can provide multiple metrics and dimensions as well
report.visists_and_visitors_by_month_and_city(0, Time.now)

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Added some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 16 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.