govuk_frontend_toolkit 3.4.2 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/CHANGELOG.md +4 -0
- data/app/assets/VERSION.txt +1 -1
- data/app/assets/docs/analytics.md +12 -0
- data/app/assets/docs/javascript.md +11 -4
- data/app/assets/javascripts/govuk/analytics/google-analytics-universal-tracker.js +23 -0
- data/app/assets/javascripts/govuk/analytics/tracker.js +7 -0
- data/app/assets/spec/unit/analytics/TrackerSpec.js +21 -0
- data/app/assets/stylesheets/_colours.scss +2 -0
- metadata +4 -4
data/app/assets/CHANGELOG.md
CHANGED
data/app/assets/VERSION.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.5.0
|
@@ -160,3 +160,15 @@ Pull `print-intent.js` into your project, and initialise it after analytics (see
|
|
160
160
|
## Error tracking
|
161
161
|
|
162
162
|
Pull `error-tracking.js` into your project, and initialise it after analytics (see [Create an analytics tracker, above](#create-an-analytics-tracker)), to track JavaScript errors.
|
163
|
+
|
164
|
+
## Tracking across domains
|
165
|
+
|
166
|
+
Once a Tracker instance has been created, tracking across domains can be set up
|
167
|
+
for pages like:
|
168
|
+
|
169
|
+
```js
|
170
|
+
GOVUK.analytics.addLinkedTrackerDomain(trackerIdHere, nameForTracker, domainToLinkTo);
|
171
|
+
```
|
172
|
+
|
173
|
+
Once this is done hits to that page will be tracked in both your local and the
|
174
|
+
named tracker, and sessions will persist to the other domain.
|
@@ -89,17 +89,24 @@ The toolkit includes a library for multivariate testing that is capable of repor
|
|
89
89
|
|
90
90
|
#### To create a new experiment
|
91
91
|
|
92
|
-
1. Log in to Google Universal Analytics, select "UA -
|
92
|
+
1. Log in to Google Universal Analytics, select "UA - 1. GOV.UK(Entire Site - Filtered)".
|
93
|
+
|
93
94
|
2. In the left column, click on Behaviour, then Experiments and follow [these instructions](https://support.google.com/analytics/answer/1745152?hl=en-GB) to set up your experiment; you will need to have edit permissions on the Universal Analytics profile. If you cannot see a "Create experiment" button, this means you don't have these permissions; you can ask someone from the Performance Analyst team to set the experiment up for you.
|
95
|
+
|
94
96
|
3. In step number 2, in our case the address of the web pages will purely be used as descriptions in reports, so we recommend you pick the addresses accordingly, ie: "www.gov.uk" and "www.gov.uk/?=variation1".
|
97
|
+
|
95
98
|
4. In step number 3, "Setting up your experiment code", select "Manually insert the code" and make a note of the Experiment ID number located under the script window.
|
99
|
+
|
96
100
|
5. Add the below code to the page you want to test.
|
97
|
-
- the contentExperimentId is the Experiment ID you retrieved in step 3
|
101
|
+
- the contentExperimentId is the Experiment ID you retrieved in step 3.
|
98
102
|
- the variantId is 0 for the original variant, 1 for the first modified variant, 2 for the second modified variant, etc.
|
99
|
-
- see section above for other elements
|
103
|
+
- see section above for other elements.
|
100
104
|
This code requires analytics to be loaded in order to run; static is the app that would load the analytics by default, which automatically happens before experiments are run.
|
101
|
-
6. Check that it works: launch the app, open the page of your app, and check that there is a cookie with the name you had picked in your experiment. You can delete the cookie and refresh the page to check whether you can be assigned to another cohort.
|
102
105
|
|
106
|
+
6. Check that it works: launch the app, open the page of your app, and check that there is a cookie with the name you had picked in your experiment. You can delete the cookie and refresh the page to check whether you can be assigned to another cohort. Then in your browser console, go to the Networks tab and search for xid and xvar. The values should correspond to your contentExperimentId and the cohort your cookie indicates you were assigned to.
|
107
|
+
|
108
|
+
7. If it works, in Google Universal Analytics, click on "Next Step" and then "Start Experiment". You can ignore the error messages relative to Experiment Code Validation as they don't concern us in our setup.
|
109
|
+
|
103
110
|
```js
|
104
111
|
var test = new GOVUK.MultivariateTest({
|
105
112
|
name: 'car_tax_button_text',
|
@@ -89,6 +89,29 @@
|
|
89
89
|
});
|
90
90
|
};
|
91
91
|
|
92
|
+
/*
|
93
|
+
https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain
|
94
|
+
trackerId - the UA account code to track the domain against
|
95
|
+
name - name for the tracker
|
96
|
+
domain - the domain to track
|
97
|
+
*/
|
98
|
+
GoogleAnalyticsUniversalTracker.prototype.addLinkedTrackerDomain = function(trackerId, name, domain) {
|
99
|
+
sendToGa('create',
|
100
|
+
trackerId,
|
101
|
+
'auto',
|
102
|
+
{'name': name});
|
103
|
+
// Load the plugin.
|
104
|
+
sendToGa('require', 'linker');
|
105
|
+
sendToGa(name + '.require', 'linker');
|
106
|
+
|
107
|
+
// Define which domains to autoLink.
|
108
|
+
sendToGa('linker:autoLink', [domain]);
|
109
|
+
sendToGa(name + '.linker:autoLink', [domain]);
|
110
|
+
|
111
|
+
sendToGa(name + '.set', 'anonymizeIp', true);
|
112
|
+
sendToGa(name + '.send', 'pageview');
|
113
|
+
};
|
114
|
+
|
92
115
|
// https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
|
93
116
|
GoogleAnalyticsUniversalTracker.prototype.setDimension = function(index, value) {
|
94
117
|
sendToGa('set', 'dimension' + index, String(value));
|
@@ -46,5 +46,12 @@
|
|
46
46
|
this.classic.setCustomVariable(index, value, name, scope);
|
47
47
|
};
|
48
48
|
|
49
|
+
/*
|
50
|
+
Add a beacon to track a page in another GA account on another domain.
|
51
|
+
*/
|
52
|
+
Tracker.prototype.addLinkedTrackerDomain = function(trackerId, name, domain) {
|
53
|
+
this.universal.addLinkedTrackerDomain(trackerId, name, domain);
|
54
|
+
};
|
55
|
+
|
49
56
|
GOVUK.Tracker = Tracker;
|
50
57
|
})();
|
@@ -71,4 +71,25 @@ describe("GOVUK.Tracker", function() {
|
|
71
71
|
});
|
72
72
|
});
|
73
73
|
|
74
|
+
describe('when adding a linked domain', function() {
|
75
|
+
beforeEach(function() {
|
76
|
+
tracker = new GOVUK.Tracker(this.config);
|
77
|
+
});
|
78
|
+
|
79
|
+
it('adds a linked domain to universal only', function() {
|
80
|
+
window._gaq = [];
|
81
|
+
tracker.addLinkedTrackerDomain('1234', 'test', 'www.example.com');
|
82
|
+
|
83
|
+
expect(window._gaq).toEqual([]);
|
84
|
+
var allArgs = window.ga.calls.allArgs()
|
85
|
+
expect(allArgs).toContain(['create', '1234', 'auto', {'name': 'test'}]);
|
86
|
+
expect(allArgs).toContain(['require', 'linker']);
|
87
|
+
expect(allArgs).toContain(['test.require', 'linker']);
|
88
|
+
expect(allArgs).toContain(['linker:autoLink', ['www.example.com']]);
|
89
|
+
expect(allArgs).toContain(['test.linker:autoLink', ['www.example.com']]);
|
90
|
+
expect(allArgs).toContain(['test.set', 'anonymizeIp', true]);
|
91
|
+
expect(allArgs).toContain(['test.send', 'pageview']);
|
92
|
+
});
|
93
|
+
});
|
94
|
+
|
74
95
|
});
|
@@ -103,8 +103,10 @@ $panel-colour: $grey-3; // Related links panel, page footer etc.
|
|
103
103
|
$canvas-colour: $grey-4; // Page background
|
104
104
|
$highlight-colour: $grey-4; // Table stripes etc.
|
105
105
|
$page-colour: $white; // The page
|
106
|
+
$discovery-colour: $fuschia; // Discovery badges and banners
|
106
107
|
$alpha-colour: $pink; // Alpha badges and banners
|
107
108
|
$beta-colour: $orange; // Beta badges and banners
|
109
|
+
$live-colour: $grass-green; // Live badges and banners
|
108
110
|
$banner-text-colour: #000; // Text colour for Alpha & Beta banners
|
109
111
|
$error-colour: #af1324; // Error text and border colour
|
110
112
|
$error-background: #fef7f7; // Error background colour
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_frontend_toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -288,7 +288,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
288
288
|
version: '0'
|
289
289
|
segments:
|
290
290
|
- 0
|
291
|
-
hash: -
|
291
|
+
hash: -3226103132821622177
|
292
292
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
293
293
|
none: false
|
294
294
|
requirements:
|
@@ -297,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
297
|
version: '0'
|
298
298
|
segments:
|
299
299
|
- 0
|
300
|
-
hash: -
|
300
|
+
hash: -3226103132821622177
|
301
301
|
requirements: []
|
302
302
|
rubyforge_project:
|
303
303
|
rubygems_version: 1.8.23
|