govuk_publishing_components 40.0.0 → 41.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +1 -79
- data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +1 -34
- data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +0 -17
- data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +0 -6
- data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +0 -7
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +8 -74
- data/app/assets/javascripts/govuk_publishing_components/dependencies.js +0 -4
- data/app/assets/javascripts/govuk_publishing_components/domain-config.js +0 -8
- data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +0 -4
- data/app/assets/javascripts/govuk_publishing_components/lib/cookie-settings.js +0 -14
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +0 -20
- data/app/assets/javascripts/govuk_publishing_components/lib/toggle.js +0 -33
- data/app/assets/javascripts/govuk_publishing_components/load-analytics.js +0 -25
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +1 -8
- data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_cards.html.erb +3 -11
- data/app/views/govuk_publishing_components/components/_contents_list.html.erb +2 -15
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +3 -19
- data/app/views/govuk_publishing_components/components/_details.html.erb +9 -11
- data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -5
- data/app/views/govuk_publishing_components/components/_intervention.html.erb +4 -4
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +7 -21
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -26
- data/app/views/govuk_publishing_components/components/_metadata.html.erb +2 -5
- data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +2 -7
- data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +0 -10
- data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +1 -3
- data/app/views/govuk_publishing_components/components/_search.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_select.html.erb +1 -2
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +1 -10
- data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +0 -1
- data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +1 -24
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -14
- data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +1 -4
- data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +0 -1
- data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +1 -7
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +1 -60
- data/app/views/govuk_publishing_components/components/docs/big_number.yml +2 -6
- data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +0 -1
- data/app/views/govuk_publishing_components/components/docs/button.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/cards.yml +3 -13
- data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +0 -33
- data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +2 -2
- data/app/views/govuk_publishing_components/components/docs/details.yml +0 -15
- data/app/views/govuk_publishing_components/components/docs/document_list.yml +11 -18
- data/app/views/govuk_publishing_components/components/docs/error_alert.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +0 -11
- data/app/views/govuk_publishing_components/components/docs/image_card.yml +0 -31
- data/app/views/govuk_publishing_components/components/docs/intervention.yml +0 -26
- data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +2 -2
- data/app/views/govuk_publishing_components/components/docs/meta_tags.yml +0 -2
- data/app/views/govuk_publishing_components/components/docs/option_select.yml +4 -16
- data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +0 -15
- data/app/views/govuk_publishing_components/components/docs/print_link.yml +2 -9
- data/app/views/govuk_publishing_components/components/docs/search.yml +12 -0
- data/app/views/govuk_publishing_components/components/docs/select.yml +0 -36
- data/app/views/govuk_publishing_components/components/docs/share_links.yml +2 -4
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +2 -25
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +0 -23
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +0 -10
- data/app/views/govuk_publishing_components/components/docs/subscription_links.yml +3 -15
- data/app/views/govuk_publishing_components/components/docs/table.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/translation_nav.yml +3 -27
- data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +1 -5
- data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +0 -2
- data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +0 -10
- data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +1 -5
- data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +0 -7
- data/lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb +1 -19
- data/lib/govuk_publishing_components/presenters/image_card_helper.rb +1 -15
- data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +2 -24
- data/lib/govuk_publishing_components/presenters/select_helper.rb +0 -4
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +0 -5
- data/lib/govuk_publishing_components/presenters/translation_nav_helper.rb +0 -7
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +3 -25
- data/app/assets/javascripts/govuk_publishing_components/analytics/analytics.js +0 -92
- data/app/assets/javascripts/govuk_publishing_components/analytics/auto-scroll-tracker.js +0 -221
- data/app/assets/javascripts/govuk_publishing_components/analytics/auto-track-event.js +0 -30
- data/app/assets/javascripts/govuk_publishing_components/analytics/cross-domain-tracking.js +0 -55
- data/app/assets/javascripts/govuk_publishing_components/analytics/custom-dimensions.js +0 -133
- data/app/assets/javascripts/govuk_publishing_components/analytics/download-link-tracker.js +0 -46
- data/app/assets/javascripts/govuk_publishing_components/analytics/ecommerce.js +0 -101
- data/app/assets/javascripts/govuk_publishing_components/analytics/error-tracking.js +0 -51
- data/app/assets/javascripts/govuk_publishing_components/analytics/explicit-cross-domain-links.js +0 -88
- data/app/assets/javascripts/govuk_publishing_components/analytics/external-link-tracker.js +0 -68
- data/app/assets/javascripts/govuk_publishing_components/analytics/google-analytics-universal-tracker.js +0 -220
- data/app/assets/javascripts/govuk_publishing_components/analytics/init.js +0 -60
- data/app/assets/javascripts/govuk_publishing_components/analytics/linked-domains.js +0 -135
- data/app/assets/javascripts/govuk_publishing_components/analytics/mailto-link-tracker.js +0 -43
- data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +0 -160
- data/app/assets/javascripts/govuk_publishing_components/analytics/pii.js +0 -115
- data/app/assets/javascripts/govuk_publishing_components/analytics/print-intent.js +0 -39
- data/app/assets/javascripts/govuk_publishing_components/analytics/static-analytics.js +0 -132
- data/app/assets/javascripts/govuk_publishing_components/analytics/track-click.js +0 -75
- data/app/assets/javascripts/govuk_publishing_components/analytics/track-select-change.js +0 -56
- data/app/assets/javascripts/govuk_publishing_components/analytics.js +0 -23
- data/app/assets/javascripts/govuk_publishing_components/components/details.js +0 -48
data/app/assets/javascripts/govuk_publishing_components/analytics/explicit-cross-domain-links.js
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
window.GOVUK = window.GOVUK || {}
|
2
|
-
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
3
|
-
|
4
|
-
(function (Modules) {
|
5
|
-
function ExplicitCrossDomainLinks ($module) {
|
6
|
-
this.$module = $module
|
7
|
-
}
|
8
|
-
|
9
|
-
ExplicitCrossDomainLinks.prototype.init = function () {
|
10
|
-
this.attribute = 'href'
|
11
|
-
this.attributeValue = this.$module.getAttribute(this.attribute)
|
12
|
-
this.eventType = 'click'
|
13
|
-
if (!this.attributeValue) {
|
14
|
-
this.attribute = 'action'
|
15
|
-
this.attributeValue = this.$module.getAttribute(this.attribute)
|
16
|
-
this.eventType = 'submit'
|
17
|
-
}
|
18
|
-
|
19
|
-
this.handleEvent = this.handleEvent.bind(this)
|
20
|
-
this.handleCookiesAccepted = this.handleCookiesAccepted.bind(this)
|
21
|
-
// Listens for the 'submit' event if the element is a form, and the 'click' event if it is a link
|
22
|
-
this.$module.addEventListener(this.eventType, this.handleEvent)
|
23
|
-
}
|
24
|
-
|
25
|
-
ExplicitCrossDomainLinks.prototype.decorate = function (element, param, attribute) {
|
26
|
-
var attributeValue = element.getAttribute(attribute)
|
27
|
-
|
28
|
-
if (!attributeValue) { return }
|
29
|
-
|
30
|
-
if (attributeValue.indexOf('?') !== -1) {
|
31
|
-
attributeValue += '&' + param
|
32
|
-
} else {
|
33
|
-
attributeValue += '?' + param
|
34
|
-
}
|
35
|
-
|
36
|
-
element.setAttribute(attribute, attributeValue)
|
37
|
-
}
|
38
|
-
|
39
|
-
ExplicitCrossDomainLinks.prototype.handleEvent = function (e) {
|
40
|
-
// prevent default: we want the link href and/or form action to be decorated before we navigate away
|
41
|
-
e.preventDefault()
|
42
|
-
var cookieBannerEngaged = window.GOVUK.cookie('cookies_preferences_set')
|
43
|
-
var cookieConsent = window.GOVUK.getConsentCookie()
|
44
|
-
|
45
|
-
if (cookieBannerEngaged !== 'true') {
|
46
|
-
// If not engaged, append only ?cookie_consent=not-engaged
|
47
|
-
this.decorate(this.$module, 'cookie_consent=not-engaged', this.attribute)
|
48
|
-
} else if (cookieConsent && cookieConsent.usage === true) {
|
49
|
-
this.handleCookiesAccepted()
|
50
|
-
} else {
|
51
|
-
this.decorate(this.$module, 'cookie_consent=reject', this.attribute)
|
52
|
-
}
|
53
|
-
|
54
|
-
// remove the event listener to avoid an infinite loop
|
55
|
-
this.$module.removeEventListener(this.eventType, this.handleEvent)
|
56
|
-
|
57
|
-
// if the element is a form, submit it. If it is a link, click it
|
58
|
-
if (this.eventType === 'submit') {
|
59
|
-
this.$module.submit()
|
60
|
-
} else {
|
61
|
-
this.$module.click()
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
ExplicitCrossDomainLinks.prototype.handleCookiesAccepted = function () {
|
66
|
-
// If the cookie banner was engaged and usage cookie accepted, append ?_ga=clientid if available and cookie_consent=accept
|
67
|
-
var element = this.$module
|
68
|
-
var attribute = this.attribute
|
69
|
-
this.decorate(element, 'cookie_consent=accept', attribute)
|
70
|
-
|
71
|
-
if (!window.ga) {
|
72
|
-
return
|
73
|
-
}
|
74
|
-
|
75
|
-
window.ga(function () {
|
76
|
-
var trackers = window.ga.getAll()
|
77
|
-
|
78
|
-
if (!trackers.length) { return }
|
79
|
-
|
80
|
-
var linker = new window.gaplugins.Linker(trackers[0])
|
81
|
-
var attrValue = element.getAttribute(attribute)
|
82
|
-
|
83
|
-
element.setAttribute(attribute, linker.decorate(attrValue))
|
84
|
-
})
|
85
|
-
}
|
86
|
-
|
87
|
-
Modules.ExplicitCrossDomainLinks = ExplicitCrossDomainLinks
|
88
|
-
})(window.GOVUK.Modules)
|
@@ -1,68 +0,0 @@
|
|
1
|
-
// = require ../vendor/polyfills-govuk-frontend-v4/Element/prototype/closest.js
|
2
|
-
;(function (global) {
|
3
|
-
'use strict'
|
4
|
-
|
5
|
-
var GOVUK = global.GOVUK || {}
|
6
|
-
|
7
|
-
GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
|
8
|
-
GOVUK.analyticsPlugins.externalLinkTracker = function (options) {
|
9
|
-
options = options || {}
|
10
|
-
GOVUK.analyticsPlugins.externalLinkTracker.options = options
|
11
|
-
document.querySelector('body').addEventListener('click', GOVUK.analyticsPlugins.externalLinkTracker.handleClick)
|
12
|
-
}
|
13
|
-
|
14
|
-
GOVUK.analyticsPlugins.externalLinkTracker.handleClick = function (event) {
|
15
|
-
var element = event.target
|
16
|
-
if (element.tagName !== 'A') {
|
17
|
-
element = element.closest('a')
|
18
|
-
}
|
19
|
-
|
20
|
-
if (!element) {
|
21
|
-
return
|
22
|
-
}
|
23
|
-
|
24
|
-
if (GOVUK.analyticsPlugins.externalLinkTracker.isExternalLink(element.getAttribute('href'))) {
|
25
|
-
GOVUK.analyticsPlugins.externalLinkTracker.trackClickEvent(element)
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
GOVUK.analyticsPlugins.externalLinkTracker.isExternalLink = function (href) {
|
30
|
-
if (!href) {
|
31
|
-
return false
|
32
|
-
}
|
33
|
-
|
34
|
-
var currentHost = GOVUK.analyticsPlugins.externalLinkTracker.getHostname()
|
35
|
-
if (href.substring(0, 4) === 'http' && href.indexOf(currentHost) === -1) {
|
36
|
-
return true
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
GOVUK.analyticsPlugins.externalLinkTracker.trackClickEvent = function (element) {
|
41
|
-
var options = { transport: 'beacon' }
|
42
|
-
var href = element.getAttribute('href')
|
43
|
-
var linkText = element.textContent.trim()
|
44
|
-
|
45
|
-
if (linkText) {
|
46
|
-
options.label = linkText
|
47
|
-
}
|
48
|
-
|
49
|
-
var externalLinkUploadCustomDimension = GOVUK.analyticsPlugins.externalLinkTracker.options.externalLinkUploadCustomDimension
|
50
|
-
if (externalLinkUploadCustomDimension !== undefined) {
|
51
|
-
// This custom dimension will be used to duplicate the url information
|
52
|
-
// that we normally send in an "event action". This will be used to join
|
53
|
-
// up with a scheduled custom upload called "External Link Status".
|
54
|
-
// We can only join uploads on custom dimensions, not on `event actions`
|
55
|
-
// where we normally add the url info.
|
56
|
-
var externalLinkToJoinUploadOn = href
|
57
|
-
|
58
|
-
GOVUK.analytics.setDimension(externalLinkUploadCustomDimension, externalLinkToJoinUploadOn)
|
59
|
-
}
|
60
|
-
GOVUK.analytics.trackEvent('External Link Clicked', href, options)
|
61
|
-
}
|
62
|
-
|
63
|
-
GOVUK.analyticsPlugins.externalLinkTracker.getHostname = function () {
|
64
|
-
return global.location.hostname
|
65
|
-
}
|
66
|
-
|
67
|
-
global.GOVUK = GOVUK
|
68
|
-
})(window)
|
@@ -1,220 +0,0 @@
|
|
1
|
-
;(function (global) {
|
2
|
-
'use strict'
|
3
|
-
|
4
|
-
var GOVUK = global.GOVUK || {}
|
5
|
-
var pii
|
6
|
-
|
7
|
-
var GoogleAnalyticsUniversalTracker = function (trackingId, fieldsObject) {
|
8
|
-
pii = new GOVUK.Pii()
|
9
|
-
|
10
|
-
function configureProfile () {
|
11
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/command-queue-reference#create
|
12
|
-
sendToGa('create', trackingId, fieldsObject)
|
13
|
-
}
|
14
|
-
|
15
|
-
function anonymizeIp () {
|
16
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#anonymizeip
|
17
|
-
sendToGa('set', 'anonymizeIp', true)
|
18
|
-
}
|
19
|
-
|
20
|
-
function disableAdFeatures () {
|
21
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#allowAdFeatures
|
22
|
-
sendToGa('set', 'allowAdFeatures', false)
|
23
|
-
}
|
24
|
-
|
25
|
-
function stripTitlePII () {
|
26
|
-
sendToGa('set', 'title', pii.stripPII(document.title))
|
27
|
-
}
|
28
|
-
|
29
|
-
function stripLocationPII () {
|
30
|
-
sendToGa('set', 'location', pii.stripPII(window.location.href))
|
31
|
-
}
|
32
|
-
|
33
|
-
// Support legacy cookieDomain param
|
34
|
-
if (typeof fieldsObject === 'string') {
|
35
|
-
fieldsObject = { cookieDomain: fieldsObject }
|
36
|
-
}
|
37
|
-
|
38
|
-
function setLinkedDomains () {
|
39
|
-
var domains = window.GOVUK.analyticsVars.primaryLinkedDomains
|
40
|
-
if (domains && domains.length > 0) {
|
41
|
-
sendToGa('require', 'linker')
|
42
|
-
sendToGa('linker:autoLink', domains)
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
configureProfile()
|
47
|
-
anonymizeIp()
|
48
|
-
disableAdFeatures()
|
49
|
-
stripTitlePII()
|
50
|
-
stripLocationPII()
|
51
|
-
setLinkedDomains()
|
52
|
-
}
|
53
|
-
|
54
|
-
GoogleAnalyticsUniversalTracker.load = function () {
|
55
|
-
/* eslint-disable */
|
56
|
-
(function (i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
|
57
|
-
(i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o),
|
58
|
-
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
|
59
|
-
})(global, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga')
|
60
|
-
/* eslint-enable */
|
61
|
-
}
|
62
|
-
|
63
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/pages
|
64
|
-
GoogleAnalyticsUniversalTracker.prototype.trackPageview = function (path, title, options) {
|
65
|
-
var pageviewObject
|
66
|
-
var trackerName = ''
|
67
|
-
|
68
|
-
if (typeof path === 'string') {
|
69
|
-
pageviewObject = { page: path }
|
70
|
-
}
|
71
|
-
|
72
|
-
if (typeof title === 'string') {
|
73
|
-
pageviewObject = pageviewObject || {}
|
74
|
-
pageviewObject.title = title
|
75
|
-
}
|
76
|
-
|
77
|
-
// Set an options object for the pageview (e.g. transport, sessionControl)
|
78
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#transport
|
79
|
-
if (typeof options === 'object') {
|
80
|
-
pageviewObject = GOVUK.extendObject(pageviewObject || {}, options)
|
81
|
-
|
82
|
-
// trackerName is optional
|
83
|
-
if (typeof options.trackerName === 'string') {
|
84
|
-
trackerName = options.trackerName + '.'
|
85
|
-
delete options.trackerName
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
function isEmptyObject (obj) {
|
90
|
-
if (typeof obj === 'undefined') {
|
91
|
-
return true
|
92
|
-
}
|
93
|
-
|
94
|
-
for (var prop in obj) {
|
95
|
-
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
96
|
-
return false
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
return JSON.stringify(obj) === JSON.stringify({})
|
101
|
-
}
|
102
|
-
|
103
|
-
if (isEmptyObject(pageviewObject)) {
|
104
|
-
sendToGa(trackerName + 'send', 'pageview')
|
105
|
-
} else {
|
106
|
-
sendToGa(trackerName + 'send', 'pageview', pageviewObject)
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/events
|
111
|
-
GoogleAnalyticsUniversalTracker.prototype.trackEvent = function (category, action, options) {
|
112
|
-
options = options || {}
|
113
|
-
var value
|
114
|
-
var trackerName = ''
|
115
|
-
var evt = {
|
116
|
-
hitType: 'event',
|
117
|
-
eventCategory: category,
|
118
|
-
eventAction: action
|
119
|
-
}
|
120
|
-
|
121
|
-
// Label is optional
|
122
|
-
if (typeof options.label === 'string') {
|
123
|
-
evt.eventLabel = options.label
|
124
|
-
delete options.label
|
125
|
-
}
|
126
|
-
|
127
|
-
// Value is optional, but when used must be an
|
128
|
-
// integer, otherwise the event will be invalid
|
129
|
-
// and not logged
|
130
|
-
if (options.value || options.value === 0) {
|
131
|
-
value = parseInt(options.value, 10)
|
132
|
-
if (typeof value === 'number' && !isNaN(value)) {
|
133
|
-
options.eventValue = value
|
134
|
-
}
|
135
|
-
delete options.value
|
136
|
-
}
|
137
|
-
|
138
|
-
// trackerName is optional
|
139
|
-
if (typeof options.trackerName === 'string') {
|
140
|
-
trackerName = options.trackerName + '.'
|
141
|
-
delete options.trackerName
|
142
|
-
}
|
143
|
-
|
144
|
-
// Prevents an event from affecting bounce rate
|
145
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/events#implementation
|
146
|
-
if (options.nonInteraction) {
|
147
|
-
options.nonInteraction = 1
|
148
|
-
}
|
149
|
-
|
150
|
-
if (typeof options === 'object') {
|
151
|
-
evt = GOVUK.extendObject(evt, options)
|
152
|
-
}
|
153
|
-
|
154
|
-
sendToGa(trackerName + 'send', evt)
|
155
|
-
}
|
156
|
-
|
157
|
-
/*
|
158
|
-
https://developers.google.com/analytics/devguides/collection/analyticsjs/social-interactions
|
159
|
-
network – The network on which the action occurs (e.g. Facebook, Twitter)
|
160
|
-
action – The type of action that happens (e.g. Like, Send, Tweet)
|
161
|
-
target – Specifies the target of a social interaction.
|
162
|
-
This value is typically a URL but can be any text.
|
163
|
-
*/
|
164
|
-
GoogleAnalyticsUniversalTracker.prototype.trackSocial = function (network, action, target, options) {
|
165
|
-
var trackingOptions = {
|
166
|
-
hitType: 'social',
|
167
|
-
socialNetwork: network,
|
168
|
-
socialAction: action,
|
169
|
-
socialTarget: target
|
170
|
-
}
|
171
|
-
|
172
|
-
trackingOptions = GOVUK.extendObject(trackingOptions, options)
|
173
|
-
|
174
|
-
sendToGa('send', trackingOptions)
|
175
|
-
}
|
176
|
-
|
177
|
-
/*
|
178
|
-
https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain
|
179
|
-
trackerId - the UA account code to track the domain against
|
180
|
-
name - name for the tracker
|
181
|
-
domain - the domain to track (must be an array of strings)
|
182
|
-
sendPageView - optional argument which controls the legacy behaviour of sending a pageview
|
183
|
-
on creation of the linked domain.
|
184
|
-
*/
|
185
|
-
GoogleAnalyticsUniversalTracker.prototype.addLinkedTrackerDomain = function (trackerId, name, domain, sendPageView) {
|
186
|
-
sendToGa('create',
|
187
|
-
trackerId,
|
188
|
-
'auto',
|
189
|
-
{ name: name })
|
190
|
-
// Load the plugin.
|
191
|
-
sendToGa(name + '.require', 'linker')
|
192
|
-
|
193
|
-
// Define which domains to autoLink.
|
194
|
-
sendToGa(name + '.linker:autoLink', domain)
|
195
|
-
|
196
|
-
sendToGa(name + '.set', 'anonymizeIp', true)
|
197
|
-
sendToGa(name + '.set', 'allowAdFeatures', false)
|
198
|
-
sendToGa(name + '.set', 'title', pii.stripPII(document.title))
|
199
|
-
sendToGa(name + '.set', 'location', pii.stripPII(window.location.href))
|
200
|
-
|
201
|
-
if (typeof sendPageView === 'undefined' || sendPageView === true) {
|
202
|
-
sendToGa(name + '.send', 'pageview')
|
203
|
-
}
|
204
|
-
}
|
205
|
-
|
206
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
|
207
|
-
GoogleAnalyticsUniversalTracker.prototype.setDimension = function (index, value) {
|
208
|
-
sendToGa('set', 'dimension' + index, String(value))
|
209
|
-
}
|
210
|
-
|
211
|
-
function sendToGa () {
|
212
|
-
if (typeof global.ga === 'function') {
|
213
|
-
global.ga.apply(global, arguments)
|
214
|
-
}
|
215
|
-
}
|
216
|
-
|
217
|
-
GOVUK.GoogleAnalyticsUniversalTracker = GoogleAnalyticsUniversalTracker
|
218
|
-
|
219
|
-
global.GOVUK = GOVUK
|
220
|
-
})(window)
|
@@ -1,60 +0,0 @@
|
|
1
|
-
var analyticsInit = function () {
|
2
|
-
'use strict'
|
3
|
-
|
4
|
-
var analyticsVars = window.GOVUK.analyticsVars || false
|
5
|
-
if (analyticsVars) {
|
6
|
-
// the property naming convention here isn't consistent, but used in static and
|
7
|
-
// govuk-account-manager-prototype, so hard to change
|
8
|
-
var primaryGaProperty = window.GOVUK.analyticsVars.gaProperty || false
|
9
|
-
|
10
|
-
var crossDomainGaProperty = window.GOVUK.analyticsVars.gaPropertyCrossDomain || false
|
11
|
-
var crossDomainLinkedDomains = window.GOVUK.analyticsVars.linkedDomains || false
|
12
|
-
}
|
13
|
-
|
14
|
-
var consentCookie = window.GOVUK.getConsentCookie()
|
15
|
-
var dummyAnalytics = {
|
16
|
-
addLinkedTrackerDomain: function () {},
|
17
|
-
setDimension: function () {},
|
18
|
-
setOptionsForNextPageView: function () {},
|
19
|
-
trackEvent: function () {},
|
20
|
-
trackPageview: function () {},
|
21
|
-
trackShare: function () {}
|
22
|
-
}
|
23
|
-
|
24
|
-
// Disable analytics by default
|
25
|
-
// This will be reversed below, if the consent cookie says usage cookies are allowed
|
26
|
-
var disabler = 'ga-disable-' + primaryGaProperty
|
27
|
-
window[disabler] = true
|
28
|
-
|
29
|
-
if (consentCookie && consentCookie.usage) {
|
30
|
-
window[disabler] = false
|
31
|
-
|
32
|
-
// Load Google Analytics libraries
|
33
|
-
window.GOVUK.StaticAnalytics.load()
|
34
|
-
|
35
|
-
if (primaryGaProperty) {
|
36
|
-
// Use document.domain in dev, preview and staging so that tracking works
|
37
|
-
// Otherwise explicitly set the domain as www.gov.uk (and not gov.uk).
|
38
|
-
var cookieDomain = (document.domain === 'www.gov.uk') ? '.www.gov.uk' : document.domain
|
39
|
-
|
40
|
-
// Configure profiles, setup custom vars, track initial pageview
|
41
|
-
var analytics = new window.GOVUK.StaticAnalytics({
|
42
|
-
universalId: primaryGaProperty,
|
43
|
-
cookieDomain: cookieDomain,
|
44
|
-
allowLinker: true
|
45
|
-
})
|
46
|
-
|
47
|
-
// Make interface public for virtual pageviews and events
|
48
|
-
window.GOVUK.analytics = analytics
|
49
|
-
|
50
|
-
// set up linking of domains for cross domain ga property
|
51
|
-
if (crossDomainLinkedDomains && crossDomainLinkedDomains.length > 0) {
|
52
|
-
window.GOVUK.analytics.addLinkedTrackerDomain(crossDomainGaProperty, 'govuk', crossDomainLinkedDomains)
|
53
|
-
}
|
54
|
-
}
|
55
|
-
} else {
|
56
|
-
window.GOVUK.analytics = dummyAnalytics
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
window.GOVUK.analyticsInit = analyticsInit
|
@@ -1,135 +0,0 @@
|
|
1
|
-
// For Universal Analytics' cross domain tracking.
|
2
|
-
window.GOVUK.analytics = window.GOVUK.analytics || {}
|
3
|
-
window.GOVUK.analytics.linkedDomains = [
|
4
|
-
'access.service.gov.uk',
|
5
|
-
'access.tax.service.gov.uk',
|
6
|
-
'account.companieshouse.gov.uk',
|
7
|
-
'accounts.manage-apprenticeships.service.gov.uk',
|
8
|
-
'account.publishing.service.gov.uk',
|
9
|
-
'add-driving-licence-check-code.service.gov.uk',
|
10
|
-
'analyse-school-performance.service.gov.uk',
|
11
|
-
'appeal-tax-tribunal.service.gov.uk',
|
12
|
-
'apply-basic-criminal-record-check.service.gov.uk',
|
13
|
-
'apply-blue-badge.service.gov.uk',
|
14
|
-
'apply-company-tachograph-card.service.gov.uk',
|
15
|
-
'apply-for-bankruptcy.service.gov.uk',
|
16
|
-
'apply-for-debt-relief-order.service.gov.uk',
|
17
|
-
'apply-for-environmental-permit.service.gov.uk',
|
18
|
-
'apply-for-eu-settled-status.homeoffice.gov.uk',
|
19
|
-
'apply-for-innovation-funding.service.gov.uk',
|
20
|
-
'apply-for-refugee-integration-loan.service.gov.uk',
|
21
|
-
'apply-licence.ozone-depleting-substances.service.gov.uk',
|
22
|
-
'apply-quota.fluorinated-gas.service.gov.uk',
|
23
|
-
'apply-quota.ozone-depleting-substances.service.gov.uk',
|
24
|
-
'apprenticeships.gov.uk',
|
25
|
-
'beta.companieshouse.gov.uk',
|
26
|
-
'biometric-residence-permit.service.gov.uk',
|
27
|
-
'businessreadinessfund.beis.gov.uk',
|
28
|
-
'catchreturn.service.gov.uk',
|
29
|
-
'checklegalaid.service.gov.uk',
|
30
|
-
'check-mot.service.gov.uk',
|
31
|
-
'check-payment-practices.service.gov.uk',
|
32
|
-
'check-vehicle-recalls.service.gov.uk',
|
33
|
-
'civil-service-careers.gov.uk',
|
34
|
-
'civilservicejobs.service.gov.uk',
|
35
|
-
'claim.redundancy-payments.service.gov.uk',
|
36
|
-
'claim-power-of-attorney-refund.service.gov.uk',
|
37
|
-
'compare-school-performance.service.gov.uk',
|
38
|
-
'complete-deputy-report.service.gov.uk',
|
39
|
-
'contractsfinder.service.gov.uk',
|
40
|
-
'coronavirus.data.gov.uk',
|
41
|
-
'coronavirus-business-volunteers.service.gov.uk',
|
42
|
-
'coronavirus-shielding-support.service.gov.uk',
|
43
|
-
'coronavirus-vulnerable-people.service.gov.uk',
|
44
|
-
'courttribunalfinder.service.gov.uk',
|
45
|
-
'create-energy-label.service.gov.uk',
|
46
|
-
'create-qr-code-poster.service.gov.uk',
|
47
|
-
'cymraeg.registertovote.service.gov.uk',
|
48
|
-
'dartford-crossing-charge.service.gov.uk',
|
49
|
-
'design-system.service.gov.uk',
|
50
|
-
'devtracker.dfid.gov.uk',
|
51
|
-
'digitalmarketplace.service.gov.uk',
|
52
|
-
'eforms.homeoffice.gov.uk',
|
53
|
-
'electronic-visa-waiver.service.gov.uk',
|
54
|
-
'employmenttribunals.service.gov.uk',
|
55
|
-
'eu-settled-status-enquiries.service.gov.uk',
|
56
|
-
'faster-uk-entry.service.gov.uk',
|
57
|
-
'finance.manage-apprenticeships.service.gov.uk',
|
58
|
-
'find-and-update.company-information.service.gov.uk',
|
59
|
-
'findapprenticeship.service.gov.uk',
|
60
|
-
'find-coronavirus-support.service.gov.uk',
|
61
|
-
'find-employer-schemes.education.gov.uk',
|
62
|
-
'flood-map-for-planning.service.gov.uk',
|
63
|
-
'flood-warning-information.service.gov.uk',
|
64
|
-
'follow.company-information.service.gov.uk',
|
65
|
-
'gender-pay-gap.service.gov.uk',
|
66
|
-
'get-fishing-licence.service.gov.uk',
|
67
|
-
'get-information-schools.service.gov.uk',
|
68
|
-
'gro.gov.uk',
|
69
|
-
'helpforhouseholds.campaign.gov.uk',
|
70
|
-
'helpwithcourtfees.service.gov.uk',
|
71
|
-
'help-with-prison-visits.service.gov.uk',
|
72
|
-
'identity.company-information.service.gov.uk',
|
73
|
-
'identity-sandbox.company-information.service.gov.uk',
|
74
|
-
'import-products-animals-food-feed.service.gov.uk',
|
75
|
-
'lastingpowerofattorney.service.gov.uk',
|
76
|
-
'live.email-dvla.service.gov.uk',
|
77
|
-
'live.dvla-web-chat.service.gov.uk',
|
78
|
-
'loststolenpassport.service.gov.uk',
|
79
|
-
'makeaplea.service.gov.uk',
|
80
|
-
'managefleetvehicles.service.gov.uk',
|
81
|
-
'manage-apprenticeships.service.gov.uk',
|
82
|
-
'manage-fish-exports.service.gov.uk',
|
83
|
-
'manage-quota.fluorinated-gas.service.gov.uk',
|
84
|
-
'manage-water-abstraction-impoundment-licence.service.gov.uk',
|
85
|
-
'match.redundancy-payments.service.gov.uk',
|
86
|
-
'mot-testing.service.gov.uk',
|
87
|
-
'nominate-uk-honour.service.gov.uk',
|
88
|
-
'notice.redundancy-payments.service.gov.uk',
|
89
|
-
'passport.service.gov.uk',
|
90
|
-
'paydvlafine.service.gov.uk',
|
91
|
-
'payments.service.gov.uk',
|
92
|
-
'publish-payment-practices.service.gov.uk',
|
93
|
-
'queens-awards-enterprise.service.gov.uk',
|
94
|
-
'recruit.manage-apprenticeships.service.gov.uk',
|
95
|
-
'register.fluorinated-gas.service.gov.uk',
|
96
|
-
'register-trailer.service.gov.uk',
|
97
|
-
'register.ozone-depleting-substances.service.gov.uk',
|
98
|
-
'registertovote.service.gov.uk',
|
99
|
-
'register-vehicle.service.gov.uk',
|
100
|
-
'registers.service.gov.uk',
|
101
|
-
'reminders.mot-testing.service.gov.uk',
|
102
|
-
'renewable-heat-calculator.service.gov.uk',
|
103
|
-
'reply-jury-summons.service.gov.uk',
|
104
|
-
'report-director-conduct.service.gov.uk',
|
105
|
-
'report.fluorinated-gas.service.gov.uk',
|
106
|
-
'report.ozone-depleting-substances.service.gov.uk',
|
107
|
-
'right-to-rent.homeoffice.gov.uk',
|
108
|
-
'right-to-work.service.gov.uk',
|
109
|
-
'ruralpayments.service.gov.uk',
|
110
|
-
'schools-financial-benchmarking.service.gov.uk',
|
111
|
-
'secured.studentfinanceni.co.uk',
|
112
|
-
'secured.studentfinancewales.co.uk',
|
113
|
-
'selfservice.payments.service.gov.uk',
|
114
|
-
'send-money-to-prisoner.service.gov.uk',
|
115
|
-
'signin.service.gov.uk',
|
116
|
-
'sorn.service.gov.uk',
|
117
|
-
'staff.helpwithcourtfees.service.gov.uk',
|
118
|
-
'student-finance.service.gov.uk',
|
119
|
-
'tax.service.gov.uk',
|
120
|
-
'teacherservices.education.gov.uk',
|
121
|
-
'teaching-vacancies.service.gov.uk',
|
122
|
-
'to-visit-or-stay-in-the-uk.homeoffice.gov.uk',
|
123
|
-
'trade-tariff.service.gov.uk',
|
124
|
-
'tribunal-response.employmenttribunals.service.gov.uk',
|
125
|
-
'ukri.org',
|
126
|
-
'update-student-loan-employment-details.service.gov.uk',
|
127
|
-
'vehicle-operator-licensing.service.gov.uk',
|
128
|
-
'vehicleenquiry.service.gov.uk',
|
129
|
-
'viewdrivingrecord.service.gov.uk',
|
130
|
-
'view-and-prove-your-rights.homeoffice.gov.uk',
|
131
|
-
'view-immigration-status.service.gov.uk',
|
132
|
-
'visa-address-update.service.gov.uk',
|
133
|
-
'visas-immigration.service.gov.uk',
|
134
|
-
'your-defra-account.defra.gov.uk'
|
135
|
-
]
|
@@ -1,43 +0,0 @@
|
|
1
|
-
//= require ../vendor/polyfills/closest.js
|
2
|
-
;(function (global) {
|
3
|
-
'use strict'
|
4
|
-
|
5
|
-
var GOVUK = global.GOVUK || {}
|
6
|
-
|
7
|
-
GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
|
8
|
-
GOVUK.analyticsPlugins.mailtoLinkTracker = function () {
|
9
|
-
document.querySelector('body').addEventListener('click', function (event) {
|
10
|
-
var element = event.target
|
11
|
-
if (element.tagName !== 'A') {
|
12
|
-
element = element.closest('a')
|
13
|
-
}
|
14
|
-
|
15
|
-
if (!element) {
|
16
|
-
return
|
17
|
-
}
|
18
|
-
|
19
|
-
var href = element.getAttribute('href')
|
20
|
-
|
21
|
-
if (!href) {
|
22
|
-
return
|
23
|
-
}
|
24
|
-
|
25
|
-
if (href.substring(0, 7) === 'mailto:') {
|
26
|
-
trackClickEvent(element, href)
|
27
|
-
}
|
28
|
-
})
|
29
|
-
|
30
|
-
function trackClickEvent (element, href) {
|
31
|
-
var options = { transport: 'beacon' }
|
32
|
-
var linkText = element.textContent
|
33
|
-
|
34
|
-
if (linkText) {
|
35
|
-
options.label = linkText.trim()
|
36
|
-
}
|
37
|
-
|
38
|
-
GOVUK.analytics.trackEvent('Mailto Link Clicked', href, options)
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
global.GOVUK = GOVUK
|
43
|
-
})(window)
|