Charted Web Traffic Analytics

Sinatra Backed & Command Line Reporting

 
$ charted -s chartedrb.com
+-------+--------+------------------------------------+ +-----------------------------------------------------+
| Total | Unique | Visits                             | | Total Visits                                        |
+-------+--------+------------------------------------+ +-----------------------------------------------------+
| 1,319 |    948 | September 2013                     | | Sep 2013 ========================================== |
| 1,173 |    950 | August 2013                        | | Aug 2013 ========================================   |
|   906 |    745 | July 2013                          | | Jul 2013 ====================================       |
|   866 |    656 | June 2013                          | | Jun 2013 ================================           |
|   789 |    539 | May 2013                           | | May 2013 ==========================                 |
|   649 |    436 | April 2013                         | | Apr 2013 =====================                      |
|   588 |    322 | March 2013                         | | Mar 2013 =================                          |
+-------+--------+------------------------------------+ +-----------------------------------------------------+
+-----------------------------------------------------+ +-------+-----+---------------------------------------+
| Total | Unique | Events                             | | Total |   % | Browsers                              |
+-----------------------------------------------------+ +-------+-----+---------------------------------------+
|   218 |    110 | Logo Clicked                       | | 2,661 | 46% | Chrome                                |
|   127 |    105 | Nav Clicked                        | |   901 | 16% | Firefox                               |
|    94 |     76 | Modal Opened                       | |   802 | 14% | Safari                                |
|    89 |     52 | Modal Closed                       | |   716 | 13% | Mozilla                               |
|    70 |     47 | Buy Button Clicked                 | |   480 |  8% | Internet Explorer                     |
|    45 |      9 | Picture Hovered                    | |   120 |  2% | Android                               |
|    10 |      8 | Purchased                          | |    12 |  0% | Opera                                 |
...


Installing Charted

# config.ru
require 'rubygems'
require 'charted'

Charted.configure do |c|
  c.email        'dev@example.com'  # exceptions sent here
  c.delete_after 365                # delete data after 1 year
  c.db_adapter   'mysql'
  c.db_host      'localhost'
  c.db_username  'root'
  c.db_password  'secret'
  c.db_database  'charted'
  c.sites        ['chartedrb.com', 'example.com']
end

run Charted::App if !ENV['CHARTED_CMD']

# ~/.bashrc or ~/.zshrc
export CHARTED_CONFIG='/path/to/config.ru'

# on the terminal
$ charted --migrate

Install with gem install charted and setup a config.ru file like any other Sinatra application.

You'll also need to export CHARTED_CONFIG='/path/to/config.ru' in your ~/.bashrc or ~/.zshrc.

When you're finished, run charted --migrate.

Website Preparation

$ charted --js > /path/to/project/charted.js

Include the charted.js file in your website. This file can be generated using the charted binary. The JavaScript file can be concatenated using your project's asset pipeline.

Reporting

$ charted --site example.com
+-------+--------+--------------------------------------+
| Total | Unique | Visits                               |
+-------+--------+--------------------------------------+
| 7,012 |  5,919 | February 2013                        |
| 6,505 |  4,722 | January 2013                         |
| 5,342 |  3,988 | December 2012                        |
...

Traffic reports are delivered via the console. Just provide the --site switch with a few letters of the domain you want to know about.

Client-side Recording

// tracking events
Charted.events("1st Button Clicked");
Charted.events("1st Button Clicked", "2nd Button Clicked");

// tracking conversions
<body data-conversions="RSS Subscribed; Item Purchased">
Charted.goals("RSS Subscribed");
Charted.goals("RSS Subscribed", "Item Purchased"); // batched

// tracking experiments
<body data-experiments="Buy Button: Blue, Green, Red">
Charted.goals("Buy Button");

Any events can be recorded with JavaScript using Charted.events().

To start tracking conversions, add the data-conversions attribute to the <body> tag on your page. Multiple goals can be separated with a semi-colon. Then use the Charted.goals() function to record when a user accomplishes the goal.

A/B testing is similar, except you use the data-experiments attribute with the format: data-experiments="LABEL: BUCKET1, BUCKET2, BUCKET3". Charted will randomly select a bucket for each visitor and add a unique class name to the body tag.


Charted is released under the BSD License and developed by Hugh Bien. Check out the source code.