andrew/split — pull request #176 by bmarini (2013-06-23 18:21:27+00:00)
Title: Add hooks for Trial#choose! and Trial#complete!

This adds two new attributes to Split.configuration,
on_trial_choose and on_trial_complete.

Set these attributes to a method name available in the
same context as the ab_test method. These methods should
accept one argument, a Trial instance.

For example:

``` ruby
Split.configuration.on_trial_choose = :log_choice

# application_controller.rb
def log_choice(trial)
logger.info "experiment=%s alternative=%s user=%s" %
[ trial.experiment.name, trial.alternative, current_user.id ]
end
```

The motivation for this is I want to store a user event when a user participates in an experiment, and when a user reaches an experiment's goal. I want to store this info somewhere besides redis, and do cohort analysis later on, where cohorts would be users who participated in a particular experiment alternative. Let me know what you think. I'm pretty new to this gem so there may be a cleaner way to do this that I'm missing.