Skip to content

Commit

Permalink
Add AB testing setup for July 2016 session
Browse files Browse the repository at this point in the history
This commit sets up AB test for the following smart answers:

* overseas-passport
* calculate-your-child-maintenance
* marriage-abroad

Cohorts across the aforementioned smart answers fall under the following.

* Start now
* Continue
* Next
  • Loading branch information
ikennaokpala committed Jul 26, 2016
1 parent dcdd78e commit 657c607
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/assets/javascripts/smart-answers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
//= require start-button-ab-test-july-2016

function browserSupportsHtml5HistoryApi() {
return !! (history && history.replaceState && history.pushState);
}

function isExpectedPath(slug) { // Used mostly during A/B testing
return window.location.pathname.split("/").join("") == slug;
}

$(document).ready(function() {
if(browserSupportsHtml5HistoryApi()) {
var formSelector = ".current form";
Expand Down
48 changes: 48 additions & 0 deletions app/assets/javascripts/start-button-ab-test-july-2016.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//= require govuk/multivariate-test

$(function(){
if(isExpectedPath("overseas-passports")) {
new GOVUK.MultivariateTest({
el: '.get-started a',
name: 'startButton_osPassport_201607',
customDimensionIndex: [13, 14],
cookieDuration: 2, // set cookie expiry to 2 days
contentExperimentId: 'cZbCgQy3SOCHEX2l6bU-eQ',
cohorts: {
original: { callback: function() {}, variantId: 0},
next: { html: 'Next', variantId: 1 },
continue: { html: 'Continue', variantId: 2 }
}
});
}

if(isExpectedPath("calculate-your-child-maintenance")) {
new GOVUK.MultivariateTest({
el: '.get-started a',
name: 'startButton_calcChildM_201607',
customDimensionIndex: [13, 14],
cookieDuration: 2, // set cookie expiry to 2 days
contentExperimentId: '02HyTKtNR-yHsYlI6JoJqg',
cohorts: {
original: { callback: function() {}, variantId: 0},
next: { html: 'Next', variantId: 1 },
continue: { html: 'Continue', variantId: 2 }
}
});
}

if(isExpectedPath("marriage-abroad")) {
new GOVUK.MultivariateTest({
el: '.get-started a',
name: 'startButton_marriageAbroad_201607',
customDimensionIndex: [13, 14],
cookieDuration: 2, // set cookie expiry to 2 days
contentExperimentId: 'ABoraDMOQCC9WjJWsTpIPg',
cohorts: {
original: { callback: function() {}, variantId: 0},
next: { html: 'Next', variantId: 1 },
continue: { html: 'Continue', variantId: 2 }
}
});
}
});

0 comments on commit 657c607

Please sign in to comment.