Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Combining vanity metrics with radiant
branch: master

This branch is even with jemmyw:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config
db/migrate
features/support
lib
public/javascripts
spec
.gitignore
README.rdoc
Rakefile
cucumber.yml
metrics_extension.rb
specs.watchr.rb

README.rdoc

Metrics

This extension enables metrics and A/B testing using the Vanity library (vanity.labnotes.org).

Upgrade

Note that this version is incompatible with the metrics data from the previous version if the bundled Vanity gem was used. Vanity is no longer bundled with the extension and must be installed separately.

Installation

Place the files for this extension within vendor/extensions/metrics in your Radiant application, and restart your server.

Via git clone:

git clone git://github.com/jemmyw/radiant-metrics-extension.git vendor/extensions/metrics

Via extension script:

script/extension install metrics

Run `rake gems` after installation for required gems.

Now run:

  • rake radiant:extensions:metrics:migrate

  • rake radiant:extensions:metrics:update

Configuration

The Vanity gem requires Redis (code.google.com/p/redis/) to be running as a datastore. Alternatively a version of Vanity with ActiveRecord support is available at github.com/jemmyw/vanity

Using page tags for metrics and A/B tests

Create metrics and A/B tests under the new metrics tab in the Radiant admin.

Now you can do the following on your pages:

<r:track name="Signup" />

This will increment a metric named Signup.

<r:ab:test name="homepage test">
  <r:a>Half your users will be shown this text</r:a>
  <r:b>The other half will be shown this text</r:b>
</r:ab:test>

This will run the A/B test named “homepage test”. Under the metrics dashboard tab you will see the results for the test.

Note: using <r:track> or <r:ab:test> will switch off caching for that page.

Using A/B test pages

You can run an A/B test by creating a new page of the type AbTest. This will alternatively display the first two children of the page in it's place.

Using Javascript for metrics

You can also track metrics via Javascript. Using the Javascript tracking allows the page to be cached. Include the following in your layout:

<script type="text/javascript" src="/javascripts/metrics-min.js"></script>

Now you can track a metric via AJAX javascript calls:

<a href="http://example.com/signup" onclick="Metrics.track('signup');">Sign up now!</a>
Something went wrong with that request. Please try again.