Class: PiwikTracker::Piwik
- Inherits:
-
Object
- Object
- PiwikTracker::Piwik
- Defined in:
- lib/piwik_tracker/piwik.rb
Overview
Piwik HTTP client piwik = Piwik.new(‘yoursite.com/piwik’, 6) piwik.request(auth_token).
url('http://yoursite.com/some-page.html').
custom_variable(:foobar, 'value').
track_page_view('Page Title')
Defined Under Namespace
Classes: Request
Constant Summary collapse
- MAX_INT =
2 ** ((['foo'].pack('p').size * 8) - 1) - 1
- HTTP_TIMEOUT =
20
- USER_AGENT =
"piwik-tracker/#{PiwikTracker::VERSION}"
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#logger ⇒ Object
writeonly
Sets the attribute logger.
Instance Method Summary collapse
-
#initialize(base_uri, site_id) ⇒ Piwik
constructor
base_uri - the location of your Piwik installation, i.e.
-
#request(auth_token = nil) ⇒ Object
generates a new request object.
-
#track(params) ⇒ Object
sends a tracking request.
Constructor Details
#initialize(base_uri, site_id) ⇒ Piwik
base_uri - the location of your Piwik installation, i.e. ‘yoursite.com/piwik’. site_id - Id of the site to be tracked
25 26 27 28 |
# File 'lib/piwik_tracker/piwik.rb', line 25 def initialize(base_uri, site_id) @base_uri = base_uri @site_id = site_id end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
20 21 22 |
# File 'lib/piwik_tracker/piwik.rb', line 20 def debug @debug end |
#logger=(value) ⇒ Object
Sets the attribute logger
21 22 23 |
# File 'lib/piwik_tracker/piwik.rb', line 21 def logger=(value) @logger = value end |
Instance Method Details
#request(auth_token = nil) ⇒ Object
generates a new request object.
Some Tracking API functionnality requires express authentication, using either the Super User token_auth, or a user with ‘admin’ access to the website.
The following features require access:
-
force the visitor IP
-
force the date & time of the tracking requests rather than track for the current datetime
-
force Piwik to track the requests to a specific VisitorId rather than use the standard visitor matching heuristic
206 207 208 |
# File 'lib/piwik_tracker/piwik.rb', line 206 def request(auth_token = nil) Request.new self, auth_token end |
#track(params) ⇒ Object
sends a tracking request
31 32 33 34 35 |
# File 'lib/piwik_tracker/piwik.rb', line 31 def track(params) send_request params.merge( 'idsite' => @site_id, 'rec' => 1, 'rand' => rand(MAX_INT) ) end |