A simple Ruby client for the Piwik API. This gem is based on Rodrigo Tassinari de Oliveira's piwik gem ( Since it hasn't been updated since 2008, I took the liberty to fork it, and finish it up.


  • Object-oriented interface to the Piwik API;
  • For now, only a small subset of the API is implemented (only basic actions)


Piwik is an open source web analytics software, written in PHP. It provides an extensive REST-like API, and this gem aims to be a simple Ruby wrapper to access this API in a Ruby-friendly way. For example:

require 'rubygems'
require 'piwik'
Piwik.auth_token = "i need to configure simple-piwik with my auth_token here"
Piwik.piwik_url = ""
site = Piwik::Site.load(1)
=> #<Piwik::Site:0xb74bf994 @name="", @config={:auth_token=>"some_auth_key", :piwik_url=>"http://your.piwi.install"}, @id=1, @main_url="", @created_at=Tue Jul 15 18:55:40 -0300 2008>
=> 3002378
user = Piwik::User.load(1, '', 'my_auth_key')
=> #<Piwik::User:0xb66bf544 @login="", @config={:auth_token=>"some_auth_key", :piwik_url=>"http://your.piwi.install"}, @id=1, @main_url="", @created_at=Tue Jul 15 18:55:40 -0300 2008>

Configuring with initializer config/initializers/simple-piwik.rb :

if Rails.env.production? 
  Piwik.piwik_url  # ""
  Piwik.auth_token # "2ad590308b1efa590a9a43ad86d3ac1s"
elsif Rails.env.development?
  #this is currently set to the same as production
  Piwik.piwik_url  # ""
  Piwik.auth_token # "2ad590308b1efa590a9a43ad86d3ac1s"


activesupport, rest-client, json


gem install simple-piwik


  • 0.6.2 New methods (pulled from yehezkielbs' fork)
    • Site#bounce_count
    • Site#sum_visits_length
    • Site#website_referrers

Plus a couple of fixes by chaddjohnson

  • 0.6.0 Merged a few updates from Mihael's fork Gem now works with Rails 3.x, and the credentials specification strategy changed slightly

  • 0.4.2 Final fix for inconsistent API outputs caused by Rails using its own version of XmlSimple.

  • 0.4.1 Quick fixed api result parsing in site creation. The API's responses are inconsistent, but I am not sure why.

  • 0.4.0 Added Piwik::Trackable controller mixing, pretty much swiped off of halfdan's piwik analytics project ( The version included in this plugin is not suitable for application tracking, and is instead geared towards tracking multiple websites stored as ActiveRecord models

  • 0.3.0 UsersManager CRUD implementation, with tests

  • 0.2.3 Started adding some tests

  • 0.2.0 Reworked plugin to also look for a rails config file called piwik.yml, and not just the .piwik user prefs file.

  • 0.0.2 2008-07-22 (riopro) Added specs for existing API methods Created RubyForge project at

  • 0.0.1 2008-07-21 (riopro) Initial release


The MIT License