Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated README, moved to markdown, update manifest

  • Loading branch information...
commit 3287ee7c118a26c3bb0774aa0fa7993ce9f32d26 1 parent e63ac57
@tpitale tpitale authored
Showing with 122 additions and 86 deletions.
  1. +1 −2  Manifest.txt
  2. +121 −0 README.md
  3. +0 −84 README.txt
View
3  Manifest.txt
@@ -1,6 +1,6 @@
History.txt
Manifest.txt
-README.txt
+README.md
Rakefile
lib/garb.rb
lib/garb/profile.rb
@@ -19,7 +19,6 @@ test/data_request_test.rb
test/fixtures/profile_feed.xml
test/fixtures/report_feed.xml
test/garb_test.rb
-test/oauth_session_test.rb
test/operator_test.rb
test/profile_test.rb
test/report_parameter_test.rb
View
121 README.md
@@ -0,0 +1,121 @@
+garb
+====
+
+ by Tony Pitale and Justin Marney
+
+ http://github.com/vigetlabs/garb
+
+Description
+-----------
+
+ Provides a Ruby API to the Google Analytics API.
+
+ http://code.google.com/apis/analytics/docs/gdata/gdataDeveloperGuide.html
+
+Basic Usage
+===========
+
+Login
+-----
+
+ > Garb::Session.login(username, password)
+
+Profiles
+--------
+
+ > Garb::Profile.all
+ > profile = Garb::Profile.all.first
+
+Define a Report *
+-----------------
+
+ class ExitsReport < Garb::Report
+ def initialize(profile)
+ super(profile) do |config|
+ config.start_date = Time.now.at_beginning_of_month
+ config.end_date = Time.now.at_end_of_month
+ config.metrics << [:exits, :pageviews, :exit_rate]
+ config.dimensions << :request_uri
+ config.sort << :exits.desc
+ config.max_results = 10
+ end
+ end
+ end
+
+Parameters
+----------
+
+ * start_date: The date of the period you would like this report to start
+ * end_date: The date to end, inclusive
+ * max_results: The maximum number of results to be returned
+
+Metrics & Dimensions
+--------------------
+
+ Metrics and Dimensions are very complex because of the ways in which the can and cannot be combined.
+
+ I suggest reading the google documentation to familiarize yourself with this.
+
+ http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html#bounceRate
+
+ When you've returned, you can pass the appropriate combinations (up to 50 metrics and 2 dimenstions)
+ to garb, as an array, of symbols. Or you can simply push a symbol into the array.
+
+Sorting
+-------
+
+ Sorting can be done on any metric or dimension defined in the request, with .desc reversing the sort.
+
+Building a Report
+-----------------
+
+ Given the class, session, and profile from above:
+
+ reports = ExitsReport.new(profile).all
+
+ reports will be an array of OpenStructs with methods for the metrics and dimensions returned.
+
+TODOS
+-----
+
+ * Sessions are currently global, which isn't awesome
+ * Single user login is the only supported method currently.
+ Intend to add hooks for using OAuth
+ * Intend to make defined report classes before more like AR
+
+Requirements
+------------
+
+ net/http
+ happymapper
+
+Install
+-------
+
+ sudo gem install garb -s http://gems.github.com
+
+License
+-------
+
+ (The MIT License)
+
+ Copyright (c) 2008 Viget Labs
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ 'Software'), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
84 README.txt
@@ -1,84 +0,0 @@
-garb
- by Tony Pitale & Justin Marney
- http://github.com/vigetlabs/garb
-
-== DESCRIPTION:
-
-Provides a Ruby API to the Google Analytics API.
-
-== BASIC USAGE:
-
- session = Garb::Session.new(email, password) # new default session
- session.get_auth_token # get the authentication token to be used
- account = Garb::Account.new(session) # access the account profiles for this session email
- profiles = account.all # get the profile list
-
- # create a new report that gets pageviews for each browser
- report = Garb::Report.new(profiles.first, session, :metrics => [:pageviews], :dimensions => [:browser], :sort => [:browser])
- entries = report.all # get the complete list
- entries.first # e.g., ['1200', 'Firefox']
-
- ****************************************************
- You could also create the report like this:
-
- report = Garb::Report.new(profiles.first, session) do |r|
- r.metrics = [:pageviews]
- r.dimensions << :browser
- r.sort = [:browser]
- end
-
- If you want to set the sort to be descending you must do this:
-
- r.sort = '-ga:browser' # the minus is used to denote descending order
-
- You could set all of your metrics, dimensions, and sort with strings. Symbols are prefixed with 'ga' for you.
-
- If you want to filter on some fields you can do this:
-
- r.filters << {:browser => '==Safari', :pageviews => '>100'}
-
- These filters will be AND'd together (Google does not support OR at this time). See the API docs for supported operators
-
-== REQUIREMENTS:
-
-net/http
-ratom
-
-== INSTALL:
-
-sudo gem install garb -s http://gems.github.com
-
-== TODO:
-
-Key entries by property name #=> {:pageviews => '120', :browser => 'Firefox'}
-or create a structure that has accessors for each of the metrics and dimensions
-
-Sorting in reverse order
-Detect if sort params are not in dimensions or metrics
-
-Filtering
-
-== LICENSE:
-
-(The MIT License)
-
-Copyright (c) 2008 Viget Labs (different license?)
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-'Software'), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please sign in to comment.
Something went wrong with that request. Please try again.