Permalink
Browse files

More docs and admin cleanup

  • Loading branch information...
1 parent 0f89651 commit de1eebfc32a91bc63fced58afeffc161495508d4 @alex-stripe alex-stripe committed Mar 4, 2013
View
@@ -66,7 +66,7 @@ Once the user has successfully completed the experiment, say paid and navigated
<script>
Abba('Checkout')
- .control('Control')
+ .control()
.variant('Text: Complete Purchase', function(){
$('form button').text('Complete Purchase');
})
@@ -80,12 +80,16 @@ You can find a more complete example under `./public/test`.
## Options
+### Persisting results
+
If set the `persist` option to `true`, then the experiment won't be reset once it has completed. In other words, that visitor will always see that particular variant, and no more results will be recorded for that visitor.
<script>
Abba('Pricing', {persist: true}).complete();
</script>
-
+
+### Weighting
+
You can set a variant weight, so some variants are used more than others:
Abba('My Checkout')
@@ -97,9 +101,11 @@ You can set a variant weight, so some variants are used more than others:
$('#test').text('Variant 2 was chosen!');
})
.start();
-
+
In the case above, the Control will be invoked 20 times more often than the other variants.
+### Flow control
+
You can continue a previously started test using `continue()`.
Abba('My Checkout')
@@ -118,6 +124,41 @@ You can reset tests using `reset()`.
Abba('My Checkout').reset();
+Lastly, you can calculate the test that you want to run server side, and just tell the JavaScript library which flow was chosen.
+
+ Abba('My Checkout').start('Variant A')
+
+### Links
+
+If you're triggering the completion of a test on a link click or a form submit, then things get a bit more complicated.
+
+You need to ensure that tracking request doesn't get lost (which can happen in some browsers if you request an image at the same time as
+navigating). If the link is navigating to an external page which you don't control, then you have no choice but to cancel the link's default
+event, wait a few milliseconds, then navigate manually:
+
+ $('a.external').click(function(e){
+ // Prevent navigation
+ e.preventDefault();
+ var href = $(this).attr('href');
+
+ Abba('My Links').complete();
+
+ setTimeout(function(){
+ window.location = href;
+ }, 400);
+ });
+
+That's far from ideal though, and it's much better to place the tracking code on the page you're going to navigate to. If you have control
+over the page, then add the following code that checks the URL's hash.
+
+ if (window.location.hash.indexOf('_abbaTestComplete') != -1) {
+ Abba('My Links').complete();
+ }
+
+Then add the hash to the link's URL:
+
+ `<a href="/blog#_abbaTestComplete">`
+
## Credits
Thanks to the following projects:
View
@@ -122,10 +122,11 @@ def ssl_enforce!
get '/admin/experiments/:id' do
@experiment = Abba::Experiment.find(params[:id])
+ redirect('/admin/experiments') and return unless @experiment
@start_at = Date.to_mongo(params[:start_at]) if params[:start_at].present?
@end_at = Date.to_mongo(params[:end_at]) if params[:end_at].present?
- @start_at ||= @experiment.created_at
+ @start_at ||= [@experiment.created_at, 30.days.ago].max
@end_at ||= Time.now.utc
@start_at = @start_at.beginning_of_day
View
@@ -50,7 +50,7 @@ def required(*atts)
variant = experiment.variants.find_by_name(params[:variant])
variant ||= experiment.variants.create!(:name => params[:variant], :control => params[:control])
-
+
variant.start!(request) if experiment.running?
prevent_caching
@@ -24,7 +24,7 @@ class Chart extends Controller
.scale(x)
.tickSize(1)
.tickPadding(12)
- .ticks(d3.time.days.utc, 1)
+ .ticks(d3.time.days.utc, 2)
.orient('bottom')
.tickFormat((d, i) -> moment(d).format('MMM Do'))
@@ -85,12 +85,12 @@ class @Abba
@variants.push(options)
this
- control: (name, options, callback) =>
+ control: (name = 'Control', options, callback) =>
if typeof options isnt 'object'
callback = options
options = {}
- options.control = true
+ options.control = true
@variant(name, options, callback)
continue: =>
@@ -203,4 +203,18 @@ select {
article {
margin: 0 0 30px 0
}
+
+ p {
+ margin: 0 0 5px 0
+
+ &:last-child {
+ margin-bottom: 0
+ }
+ }
+
+ ul {
+ padding: 0
+ margin: 0
+ list-style: none
+ }
}
@@ -15,9 +15,17 @@
<article class="container">
<h3>Actions</h3>
- <a href="/admin/experiments/<%= @experiment.id %>/toggle" data-method="put" data-confirm="Are you sure?">
- <%= @experiment.running? ? 'End experiment' : 'Start experiment' %>
- </a>
+ <p>
+ <a href="/admin/experiments/<%= @experiment.id %>/toggle" data-method="put" data-confirm="Are you sure?">
+ <%= @experiment.running? ? 'End experiment' : 'Start experiment' %>
+ </a>
+ </p>
+
+ <p>
+ <a href="/admin/experiments/<%= @experiment.id %>" data-method="delete" data-confirm="Are you sure you want to delete this experiment?">
+ Delete experiment
+ </a>
+ </p>
</article>
<article class="container">

0 comments on commit de1eebf

Please sign in to comment.