govuk_frontend_toolkit
Advanced tools
Comparing version 4.13.0 to 4.14.0
@@ -0,1 +1,7 @@ | ||
# 4.14.0 | ||
- Allow use of multiple GA customDimensionIndex. See [this section](https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/javascript.md#using-google-custom-dimensions-with-your-own-statistical-model) of the documentation for more information. | ||
- Configurable duration (in days) for AB Test cookie. See [this section](https://github.com/alphagov/govuk_frontend_toolkit/blob/master/docs/javascript.md#multivariate-test-framework) of the documentation for more information. | ||
- Allow base scripts to run within a module loader. See [this PR](https://github.com/alphagov/govuk_frontend_toolkit/pull/290) for more information. | ||
# 4.13.0 | ||
@@ -2,0 +8,0 @@ |
(function(global) { | ||
"use strict"; | ||
var $ = global.jQuery; | ||
var GOVUK = global.GOVUK || {}; | ||
@@ -5,0 +6,0 @@ |
(function(global) { | ||
"use strict"; | ||
var $ = global.jQuery; | ||
var GOVUK = global.GOVUK || {}; | ||
@@ -5,0 +6,0 @@ |
(function(global) { | ||
"use strict"; | ||
var $ = global.jQuery; | ||
var GOVUK = global.GOVUK || {}; | ||
@@ -5,0 +6,0 @@ |
@@ -21,2 +21,3 @@ (function(global) { | ||
this._loadOption(options, 'contentExperimentId', null); | ||
this._loadOption(options, 'cookieDuration', 30); | ||
@@ -73,3 +74,3 @@ if (this.runImmediately) { | ||
cohort = this.chooseRandomCohort(); | ||
GOVUK.cookie(this.cookieName(), cohort, {days: 30}); | ||
GOVUK.cookie(this.cookieName(), cohort, {days: this.cookieDuration}); | ||
} | ||
@@ -80,10 +81,19 @@ return cohort; | ||
MultivariateTest.prototype.setCustomVar = function(cohort) { | ||
if (this.customDimensionIndex) { | ||
GOVUK.analytics.setDimension( | ||
this.customDimensionIndex, | ||
this.cookieName() + "__" + cohort | ||
); | ||
if (this.customDimensionIndex && | ||
this.customDimensionIndex.constructor === Array) { | ||
for (var index = 0; index < this.customDimensionIndex.length; index++) { | ||
this.setDimension(cohort, this.customDimensionIndex[index]) | ||
} | ||
} else if (this.customDimensionIndex) { | ||
this.setDimension(cohort, this.customDimensionIndex) | ||
} | ||
}; | ||
MultivariateTest.prototype.setDimension = function(cohort, dimension) { | ||
GOVUK.analytics.setDimension( | ||
dimension, | ||
this.cookieName() + "__" + cohort | ||
); | ||
}; | ||
MultivariateTest.prototype.setUpContentExperiment = function(cohort) { | ||
@@ -90,0 +100,0 @@ var contentExperimentId = this.contentExperimentId; |
{ | ||
"name": "govuk_frontend_toolkit", | ||
"version": "4.13.0", | ||
"version": "4.14.0", | ||
"description": "npm package for using the GOV.UK frontend toolkit", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -1,1 +0,1 @@ | ||
4.13.0 | ||
4.14.0 |
448492
1010