GACE
Google Analytics Content Experiments + Rails = AWESOME
Installation
Add this line to your application's Gemfile:
gem 'gace'
Update your view layout to include the necessary javascript. Make sure to include the javascript at the very top of your head element (per Google Analytics installation instructions).
<<!DOCTYPE html>
<html>
<head>
<%= gace_javascript_include %>
</head>
<body>
</body>
</html>
Usage
Setup experiment in Google Analytics
Configure each variation with a different gace_var parameter value.
example:
- control:
http://mysite.com/signup - variation one:
http://mysite.com/signup?gace_var=expensive - variation two:
http://mysite.com/signup?gace_var=cheap
Make sure to record the newly created experiment ID.
Configure the experiment within Rails
class UsersController < ApplicationController
def show
define_experiment :test_pricing, '28391929-0'
end
end
Create views for experiment variations
- Create a directory for the experiment:
app/experiments/EXPERIMENT_NAME(ex: app/experiments/test_pricing) - Create a directory for each experiment variation. The directory name must match the
gace_varparameter used when setting up the experiment in Google Analytics. (ex:app/experiments/test_pricing/expensiveandapp/experiments/test_pricing/cheap) - Create any views/partials to be used for that variation. Each directory should mirror structure used by app/views and will override
the default views if one exists. (ex:
app/experiments/test_pricing/expensive/users/show.html.erb)
Contributing
- Fork it ( https://github.com/thegarage/gace/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request