Low commit activity in last 3 years
Ruby client for Fathom Analytics server.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 11.1, >= 11.1.3
~> 2.7, >= 2.7.5
~> 12.0
~> 3.0
~> 6.0
~> 3.8, >= 3.8.3

Runtime

~> 2.7, >= 2.7.10
 Project Readme

CI Specs Gem Version

Fathom Analytics Ruby Client

A Ruby interface to Fathom Analytics server.

Installation

Add this line to your application's Gemfile:

gem 'fathom_analytics'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install fathom_analytics

Usage

Creating an instance of the API client:

api = FathomAnalytics::Api.new(url: 'https://example.com', email: '', password: '')

Authentication:

api.authenticate

Note: Any other api call without prior authentication will implicitly call authenticate.

Get all sites:

api.sites

Add a new site:

api.add_site(name: 'demo')

Remove a site:

api.remove_site(id: 1)

Get realtime site stats:

api.site_realtime_stats(id: 1)

Get site stats:

api.site_stats(id: 1, from: 1577862000, to: 1609484399)

Get aggregated site stats:

api.site_agg_stats(id: 1, from: 1577862000, to: 1609484399)

Get aggregated page stats:

api.page_agg_stats(id: 1, from: 1577862000, to: 1609484399)

Get aggregated page views:

api.page_agg_page_views_stats(id: 1, from: 1577862000, to: 1609484399)

Get aggregated referrer stats:

api.referrer_agg_stats(id: 1, from: 1577862000, to: 1609484399)

Get aggregated referrer page views:

api.referrer_agg_page_views_stats(id: 1, from: 1577862000, to: 1609484399)

Pagination

Pagination is supported through offset and limit params.

api.page_agg_page_views_stats(id: 1, from: 1577862000, to: 1609484399, offset: 10, limit: 10) # Second page

The default values for paginations params are as follows:

  1. limit = 50
  2. offset = 0

Handling API Errors

The api call will raise an error FathomAnalytics::Error when it fails.

begin
  api.authenticate
rescue FathomAnalytics::Error => e
  # Log and handle the error
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.