mixcloud/django-experiments — pull request #103 by dougvk (2013-03-07 01:44:27+00:00)
Title: EmployInsight, LLC A/B testing contributions

1. Add CSRF Middleware
* **What it does:** ensures CSRF token included on every response from server.
* **Why:** Since goal attainment in django-experiments uses a POST, we needed a CSRF token included with every response from the server so the goal POST doesn't fail.
2. Add enrollments
* **What it does:** gets all the current users' enrollments and creates a javascript variable, experiments.enrollments, which is an array of the current users' experiments and alternatives.
* **Why:** Helpful for writing client-side scripts. We made use of it in our codebase to instantiate different Backbone views based on the users enrollments.
3. Trigger javascript goal
* **What it does:** every time the django-experiments framework obtains a goal (this can happen many ways - through a POST to server which returns a 1x1 image, cookie which contains a goal, or click triggered goal), trigger an event (namely 'goal-attained') on the experiments variable, so that we can listen to that event client-side and perform something.
* **Why:** We use this to run javascript on goal attainment, e.g. sending the event to Google Analytics or Optimizely.
4. Bucket user via URL params
* **What it does:** create a url with the params exp= and alt= and django-experiments will bucket the user into that alternative _**if the user isn't already assigned an alternative**_.
* **Why:** We found it useful to be able to trigger an alternative via URL for bucketing in our ad-campaigns.

_**mixcloud**, we've been using your django-experiments framework extensively here at **EmployInsight**. We’ve found these additions to add helpful hooks for integrating into existing tools and writing intelligent, experiment-aware client-side code. Let us know your thoughts! It would be great to get these features into django-experiments._