{"id":17234388,"url":"https://github.com/sija/garb","last_synced_at":"2025-04-12T21:33:48.254Z","repository":{"id":3282798,"uuid":"4323095","full_name":"Sija/garb","owner":"Sija","description":"A Ruby wrapper for the Google Analytics API","archived":false,"fork":false,"pushed_at":"2023-12-14T13:14:27.000Z","size":400,"stargazers_count":147,"open_issues_count":3,"forks_count":51,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-12T10:57:07.107Z","etag":null,"topics":["api","google-analytics","ruby"],"latest_commit_sha":null,"homepage":"http://sija.github.io/garb/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"adriandulic/garb","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sija.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"Sija","custom":["https://paypal.me/sijawusz","https://revolut.me/sija"]}},"created_at":"2012-05-14T11:34:55.000Z","updated_at":"2022-08-30T08:58:32.000Z","dependencies_parsed_at":"2023-12-14T14:29:37.240Z","dependency_job_id":"65128384-dbc7-4891-b755-f8a92afca3cf","html_url":"https://github.com/Sija/garb","commit_stats":{"total_commits":260,"total_committers":28,"mean_commits":9.285714285714286,"dds":"0.49230769230769234","last_synced_commit":"c0403ce0cad462af1286c5b926ed5fb4c1c7aff3"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sija%2Fgarb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sija%2Fgarb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sija%2Fgarb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sija%2Fgarb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sija","download_url":"https://codeload.github.com/Sija/garb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248636810,"owners_count":21137527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","google-analytics","ruby"],"created_at":"2024-10-15T05:29:16.360Z","updated_at":"2025-04-12T21:33:48.235Z","avatar_url":"https://github.com/Sija.png","language":"Ruby","readme":"Garb [![Gem Version](https://badge.fury.io/rb/garb.svg)](https://badge.fury.io/rb/garb) [![CI](https://github.com/Sija/garb/actions/workflows/ci.yml/badge.svg)](https://github.com/Sija/garb/actions/workflows/ci.yml) [![License](https://img.shields.io/github/license/Sija/garb.svg)](https://github.com/Sija/garb/blob/master/LICENSE)\n====\n\n  https://github.com/Sija/garb\n\nGoogle Shutting Down Deprecated Auth on April 20th, 2015\n--------------------------------------------------------\n\nOn April 20th, Google will be shutting down ClientLogin, AuthSub, and OAuth 1.0. https://groups.google.com/forum/#!topic/google-analytics-api-notify/g8wbdUqEDd0\n\nLegato\n------\n\n  There's rewritten and (moar) actively maintained version of the library in the form of [Legato](https://github.com/tpitale/legato).\n  You might want to check it out as it's mostly compatible with `Garb`.\n\nImportant Changes\n-----------------\n\n  This fork contains heavily modified version of vigetlab's `Garb` library.\n  It works only with version 3 of Google API.\n\n  Please read CHANGELOG.\n\nDescription\n-----------\n\n  Provides a Ruby API to the Google Analytics API.\n\n  https://developers.google.com/analytics/devguides/reporting/core/v3/coreDevguide\n\nBasic Usage\n===========\n\nSingle User Login\n-----------------\n\n```ruby\nGarb::Session.api_key = api_key # required for 2-step authentication\nGarb::Session.login(username, password)\n```\n\nOAuth Access Token\n------------------\n\n```ruby\nGarb::Session.access_token = access_token # an instance of OAuth2::Client\n```\n\nAccounts, WebProperties, Profiles, and Goals\n--------------------------------------------\n\n```ruby\nGarb::Management::Account.all\nGarb::Management::WebProperty.all\nGarb::Management::Profile.all\nGarb::Management::Goal.all\n```\n\nProfiles for a UA- Number (a WebProperty)\n-----------------------------------------\n\n```ruby\nprofile = Garb::Management::Profile.all.detect { |p| p.web_property_id == 'UA-XXXXXXX-X' }\n```\n\nDefine a Report Class\n---------------------\n\n```ruby\nclass Exits\n  extend Garb::Model\n\n  metrics :exits, :pageviews\n  dimensions :page_path\nend\n```\n\nGet the Results\n---------------\n\n```ruby\nExits.results(profile, filters: { :page_path.eql =\u003e '/' })\n```\n\n  OR shorthand\n\n```ruby\nprofile.exits(filters: { :page_path.eql =\u003e '/' })\n```\n\n  Be forewarned, these numbers are for the last **30** days and may be slightly different from the numbers displayed in Google Analytics' dashboard for **1 month**.\n\nOther Parameters\n----------------\n\n  * __start_date__: The date of the period you would like this report to start\n  * __end_date__: The date to end, inclusive\n  * __limit__: The maximum number of results to be returned\n  * __offset__: The starting index\n  * __all__: Return all results if true (which might result in several requests to GAPI)\n  * __sampling_level__: Specify precision vs speed strategy (`default`, `faster`, `greater_precision`)\n\nMetrics \u0026 Dimensions\n--------------------\n\n  **Metrics and Dimensions are very complex because of the ways in which they can and cannot be combined.**\n\n  I suggest reading the google documentation to familiarize yourself with this.\n\n  https://developers.google.com/analytics/devguides/reporting/core/dimsmets#q=bouncerate\n\n  When you've returned, you can pass the appropriate combinations to Garb, as symbols.\n\nFiltering\n---------\n\n  Google Analytics supports a significant number of filtering options.\n\n  https://developers.google.com/analytics/devguides/reporting/core/v3/reference#filters\n\n  Here is what we can do currently:\n  (the operator is a method on a symbol for the appropriate metric or dimension)\n\n  Operators on metrics:\n\n```ruby\n:eql      =\u003e '==',\n:not_eql  =\u003e '!=',\n:gt       =\u003e '\u003e',\n:gte      =\u003e '\u003e=',\n:lt       =\u003e '\u003c',\n:lte      =\u003e '\u003c='\n```\n\n  Operators on dimensions:\n\n```ruby\n:matches          =\u003e '==',\n:does_not_match   =\u003e '!=',\n:contains         =\u003e '=~',\n:does_not_contain =\u003e '!~',\n:substring        =\u003e '=@',\n:not_substring    =\u003e '!@'\n```\n\n  Given the previous Exits example report in shorthand, we can add an option for filter:\n\n```ruby\nprofile.exits(filters: { :page_path.eql =\u003e '/extend/effectively-using-git-with-subversion/' })\n```\n\nSSL\n---\n\n  Version 0.2.3 includes support for real ssl encryption for SINGLE USER authentication. First do:\n\n```ruby\nGarb::Session.login(username, password, secure: true)\n```\n\n  Next, be sure to download https://curl.haxx.se/ca/cacert.pem into your application somewhere.\n  Then, point `Garb.ca_cert_file` property to that file.\n\n  For whatever reason, simply creating a new certificate store and setting the defaults would\n  not validate the google ssl certificate as authentic.\n\nOPEN / READ TIMEOUT\n-------------------\n\n  The open and read timeout values used with the network client (Net::HTTP) are configurable.\n  Both values default to 60 seconds.\n\n```ruby\nGarb.open_timeout = 3\nGarb.read_timeout = 3\n```\n\nTODOS\n-----\n\n  * rebuild AND/OR filtering in Garb::Model\n\nRequirements\n------------\n\n  * active_support \u003e= 2.2\n  * multi_json \u003e= 1.3\n\nRequirements for Testing\n------------------------\n\n  * shoulda\n  * mocha\n  * bourne\n\nInstall\n-------\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem 'garb'\n```\n\nThen run:\n\n```sh\nbundle install\n```\n\nContributors\n------------\n\n  Many Thanks, for all their help, goes to:\n\n  * Patrick Reagan\n  * Justin Marney\n  * Nick Plante\n  * James Cook\n  * Chris Gunther\n  * Sijawusz Pur Rahnama\n","funding_links":["https://github.com/sponsors/Sija","https://paypal.me/sijawusz","https://revolut.me/sija"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsija%2Fgarb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsija%2Fgarb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsija%2Fgarb/lists"}