fathom_analytics

Ruby client for Fathom Analytics server.


License
MIT
Install
gem install fathom_analytics -v 0.1.1

Documentation

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.