Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A simple Ruby client for the Piwik API

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 script
Octocat-spinner-32 test
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 simple-piwik.gemspec
README.rdoc

simple-piwik

A client for the Piwik API compatible with Rails 3.x

require 'rubygems'
require 'piwik'
Piwik.auth_token = "i need to configure simple-piwik with my auth_token here"
Piwik.piwik_url = "http://piwik.mypiwikdomain.org"
site = Piwik::Site.load(1)
=> #<Piwik::Site:0xb36ax935 @name="Examples.com", @config={:auth_token=>"my_auth_key", :piwik_url=>"http://piwik.mypiwikdomain.org"}, @id=1, @main_url="http://www.examples.com", @created_at=Thu Oct 20 22:55:42 +0100 2023>
site.pageviews(:month, Date.today)
=> 3002378
user = Piwik::User.load(1, 'http://piwik.mypiwikdomain.org', 'my_auth_key')
=> #<Piwik::User:0xa108ac955 @login="Examples.com", @config={:auth_token=>"my_auth_key", :piwik_url=>"http://piwik.mypiwikdomain.org"}, @id=1, @main_url="http://www.examples.com", @created_at=Thu Oct 20 22:55:43 -0100 2023>

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

if Rails.env.production? 
  Piwik.piwik_url  = "http://piwik.mypiwikdomain.org"
  Piwik.auth_token = "2ad590308b1efa590a9a43ad86d3ac1s"
elsif Rails.env.development?
  #this is currently set to the same as production
  Piwik.piwik_url  = "http://piwik.mypiwikdomain.org"
  Piwik.auth_token = "2ad590308b1efa590a9a43ad86d3ac1s"
end

Piwik website (piwik.org)

Piwik API reference (dev.piwik.org/trac/wiki/API/Reference)

REQUIREMENTS:

activesupport, rest-client, json

INSTALL:

gem install simple-piwik
Something went wrong with that request. Please try again.