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