Open-source Web analytics
JavaScript Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Pwnalytics is an open-source Web analytics solution. This project contains the
two JavaScript pieces loaded by Website users.


The Pwnalytics JS has been tested and works against the following browsers:
* Chromium / Google Chrome 6.0+
* Firefox 3.6+
* Mobile Safari in iOS 3+
* Internet Explorer 6+

Patches for extending compatibility are always welcome.


The deployment process is heavily inspired from Google Analytics. Tracked pages
should include the script in bin/insert.min.js in a
<script type="text/javascript"> tag at the end of their <head> tag. Find/replace
the following strings:
* AA123456 -- the property ID
* bin/p.min.js -- a URL that serves the main JS file at bin/p.min.js

The analytics server should serve bin/p.min.js, after find-replacing the
* bin/p.gif -- URL that receives GETs with analytics data

The analytics server should serve bin/p.gif in response to analytics data GETs,
to keep browsers happy.

The analytic data GETs parameters follow these conventions:
* __ is the event name ('page' is a pageview, everything else is user-defined)
* Params that start with __ are session parameters
** __pid is the property ID
** __uid is a user ID that persists across visits from the same browser
* All other params are user-defined.

The client-side JavaScript is provided the following API for posting analytics
data to the server.
* _paq.push('eventName') sends an event with nothing but a name
* _paq.push(['eventname', {param: 'value'}]) sends an event with metadata
* _paq.push(function() { ... }) calls a function after Pwnalytics is loaded
* _paq.push({property: 'value'}) sets a session property
* _paq.length counts events posted by _paq.push but not processed by the server

After Pwnalytics is loaded, _paq is extended with a few more features. These
should always be used in a function passed to _paq.push, to ensure that
Pwnalytics has loaded.
* _paq.reset() resets the session; the user UID will change as a consequence


Pwnalytics requires RubyGems, Jasmine, and Juicer with the YUI Compressor and
JSLint extensions. Once dependencies are installed, the following command will
build and test both the development and production versions of the library. 


The dependencies can be downloaded from the following locations:
* RubyGems -- 
* Jasmine -- gem install jasmine
* Juicer -- gem install juicer
* Juicer extensions -- juicer install jslint; juicer install yui_compressor


Testing is fully automated using Jasmine. All patches should add tests for the
changed functionality in the spec/ directory.

For maximum iterating speed, keep a Jasmine testing server running.

1. Start the server by running

    rake jasmine

2. Make some changes to the source code, then rebuild

    rake build
3. Load or refresh http://localhost:8888 in your browser.