From 1e6ac98a01cea1fac39076476d851f783a0a14ba Mon Sep 17 00:00:00 2001 From: Ikenna Okpala Date: Thu, 21 Jul 2016 16:48:45 +0100 Subject: [PATCH] Add AB testing setup for July 2016 session 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 The isStartPage checks that the current path matches the slug of the smart answers that has been identified for A/B testing. It splits the pathname with the forward slash delimiter and joins all. This in effect a combination of all the character in the path for the current page and in effect return true for only start page paths that equal the defined slug. --- app/assets/javascripts/smart-answers.js | 7 +++ .../start-button-ab-test-july-2016.js | 48 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 app/assets/javascripts/start-button-ab-test-july-2016.js diff --git a/app/assets/javascripts/smart-answers.js b/app/assets/javascripts/smart-answers.js index ddf380dcbd3..9711319ab79 100644 --- a/app/assets/javascripts/smart-answers.js +++ b/app/assets/javascripts/smart-answers.js @@ -1,3 +1,10 @@ +//= require start-button-ab-test-july-2016 + +var SmartAnswer = SmartAnswer || {}; +SmartAnswer.isStartPage = function(slug) { // Used mostly during A/B testing + return window.location.pathname.split("/").join("") == slug; +} + function browserSupportsHtml5HistoryApi() { return !! (history && history.replaceState && history.pushState); } diff --git a/app/assets/javascripts/start-button-ab-test-july-2016.js b/app/assets/javascripts/start-button-ab-test-july-2016.js new file mode 100644 index 00000000000..0ddbecec71e --- /dev/null +++ b/app/assets/javascripts/start-button-ab-test-july-2016.js @@ -0,0 +1,48 @@ +//= require govuk/multivariate-test + +$(function(){ + if(SmartAnswer.isStartPage("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(SmartAnswer.isStartPage("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(SmartAnswer.isStartPage("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 } + } + }); + } +});