govuk_publishing_components 34.4.2 → 34.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +1 -29
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +0 -1
  4. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +2 -2
  5. data/app/assets/javascripts/govuk_publishing_components/dependencies.js +0 -10
  6. data/app/assets/javascripts/govuk_publishing_components/load-analytics.js +126 -30
  7. data/app/assets/javascripts/govuk_publishing_components/modules.js +7 -2
  8. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +8 -4
  9. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  10. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +3 -3
  11. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +33 -4
  12. data/config/locales/ar.yml +6 -2
  13. data/config/locales/az.yml +6 -2
  14. data/config/locales/be.yml +6 -2
  15. data/config/locales/bg.yml +6 -2
  16. data/config/locales/bn.yml +6 -2
  17. data/config/locales/cs.yml +6 -2
  18. data/config/locales/cy.yml +6 -2
  19. data/config/locales/da.yml +6 -2
  20. data/config/locales/de.yml +6 -2
  21. data/config/locales/dr.yml +6 -2
  22. data/config/locales/el.yml +6 -2
  23. data/config/locales/en.yml +7 -3
  24. data/config/locales/es-419.yml +6 -2
  25. data/config/locales/es.yml +6 -2
  26. data/config/locales/et.yml +6 -2
  27. data/config/locales/fa.yml +6 -2
  28. data/config/locales/fi.yml +6 -2
  29. data/config/locales/fr.yml +6 -2
  30. data/config/locales/gd.yml +6 -2
  31. data/config/locales/gu.yml +6 -2
  32. data/config/locales/he.yml +6 -2
  33. data/config/locales/hi.yml +6 -2
  34. data/config/locales/hr.yml +6 -2
  35. data/config/locales/hu.yml +6 -2
  36. data/config/locales/hy.yml +6 -2
  37. data/config/locales/id.yml +6 -2
  38. data/config/locales/is.yml +6 -2
  39. data/config/locales/it.yml +6 -2
  40. data/config/locales/ja.yml +6 -2
  41. data/config/locales/ka.yml +6 -2
  42. data/config/locales/kk.yml +6 -2
  43. data/config/locales/ko.yml +6 -2
  44. data/config/locales/lt.yml +6 -2
  45. data/config/locales/lv.yml +6 -2
  46. data/config/locales/ms.yml +6 -2
  47. data/config/locales/mt.yml +6 -2
  48. data/config/locales/nl.yml +6 -2
  49. data/config/locales/no.yml +6 -2
  50. data/config/locales/pa-pk.yml +6 -2
  51. data/config/locales/pa.yml +6 -2
  52. data/config/locales/pl.yml +6 -2
  53. data/config/locales/ps.yml +6 -2
  54. data/config/locales/pt.yml +6 -2
  55. data/config/locales/ro.yml +6 -2
  56. data/config/locales/ru.yml +6 -2
  57. data/config/locales/si.yml +6 -2
  58. data/config/locales/sk.yml +6 -2
  59. data/config/locales/sl.yml +6 -2
  60. data/config/locales/so.yml +6 -2
  61. data/config/locales/sq.yml +6 -2
  62. data/config/locales/sr.yml +6 -2
  63. data/config/locales/sv.yml +6 -2
  64. data/config/locales/sw.yml +6 -2
  65. data/config/locales/ta.yml +6 -2
  66. data/config/locales/th.yml +6 -2
  67. data/config/locales/tk.yml +6 -2
  68. data/config/locales/tr.yml +6 -2
  69. data/config/locales/uk.yml +6 -2
  70. data/config/locales/ur.yml +6 -2
  71. data/config/locales/uz.yml +6 -2
  72. data/config/locales/vi.yml +6 -2
  73. data/config/locales/zh-hk.yml +6 -2
  74. data/config/locales/zh-tw.yml +6 -2
  75. data/config/locales/zh.yml +6 -2
  76. data/lib/govuk_publishing_components/version.rb +1 -1
  77. data/node_modules/axe-core/README.md +1 -1
  78. data/node_modules/axe-core/axe.js +175 -129
  79. data/node_modules/axe-core/axe.min.js +2 -2
  80. data/node_modules/axe-core/package.json +27 -27
  81. data/node_modules/axe-core/sri-history.json +4 -0
  82. metadata +3 -4
  83. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46eb0c57654df81f9449b23710fd6373f928fa85385572cf6d6fe1f1c74b45dc
4
- data.tar.gz: 5eeb41e690030e82f1733d7591c434a779ccd967631c8bcf90eb72d277d52d35
3
+ metadata.gz: b707429deb149f910265dd604cb0f9eb30836f1e4a0c87a0dcf169ca5f28f244
4
+ data.tar.gz: 6687ea613dd5bfe99e7098506acc5965a3f025f5d0a4e75ce5203835d810c3a3
5
5
  SHA512:
6
- metadata.gz: 47d3ec0bc04cc6203f20dbac2e79bd51e2d8e88cc192198838441f128b5d27bcbf4444f763f522df3b0a251643cd1091545a179cc6d250307590590024cfe3f2
7
- data.tar.gz: 411ffd5781bffd1c60faf5fa2f1e692ded901091c9a7424f17198f940c000c19ada2f3e28b1ea591274d1658c8ebe82a622dddca01a419635520e0749dddf41d
6
+ metadata.gz: fc4ecc673dbc67b7721f56127962ffc48aa66a54d5ede115c8b1d773a45f0e59683708ebb075e70ec1cf618a95eaf0b379e5928ef28f98ea2194dcf41857cbe7
7
+ data.tar.gz: 60647d60da042e96eecf6ddec99c8717a5f4b9b1aebb110a3916a4b1f519d2e847bb5ef475bef048a7618b048e7efd9c7156a89ecc6ed115b1041a057c9ea43f
@@ -6,39 +6,11 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
6
6
  'use strict'
7
7
 
8
8
  var core = {
9
- load: function () {
10
- var firstScript = document.getElementsByTagName('script')[0]
11
- var newScript = document.createElement('script')
12
- newScript.async = true
13
-
14
- // initialise GTM
15
- window.dataLayer = window.dataLayer || []
16
- window.dataLayer.push({ 'gtm.blocklist': ['customPixels', 'customScripts', 'html', 'nonGoogleScripts'] })
17
- window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' })
18
-
19
- var auth = window.GOVUK.analyticsGa4.vars.auth || ''
20
- var preview = window.GOVUK.analyticsGa4.vars.preview || ''
21
- if (auth) {
22
- auth = '&gtm_auth=' + auth
23
- }
24
- if (preview) {
25
- preview = '&gtm_preview=' + preview + '&gtm_cookies_win=x'
26
- }
27
-
28
- this.googleSrc = 'https://www.googletagmanager.com/gtm.js?id=' + window.GOVUK.analyticsGa4.vars.id + auth + preview
29
- newScript.src = this.googleSrc
30
- firstScript.parentNode.insertBefore(newScript, firstScript)
31
- },
32
-
33
9
  sendData: function (data) {
34
- data.govuk_gem_version = this.getGemVersion()
10
+ data.govuk_gem_version = window.GOVUK.analyticsGa4.vars.gem_version
35
11
  window.dataLayer.push(data)
36
12
  },
37
13
 
38
- getGemVersion: function () {
39
- return window.GOVUK.analyticsGa4.vars.gem_version || 'not found'
40
- },
41
-
42
14
  trackFunctions: {
43
15
  findTrackingAttributes: function (clicked, trackingTrigger) {
44
16
  if (clicked.hasAttribute('[' + trackingTrigger + ']')) {
@@ -7,4 +7,3 @@
7
7
  //= require ./analytics-ga4/ga4-link-tracker
8
8
  //= require ./analytics-ga4/ga4-event-tracker
9
9
  //= require ./analytics-ga4/ga4-ecommerce-tracker
10
- //= require ./analytics-ga4/init-ga4
@@ -76,7 +76,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
76
76
 
77
77
  CookieBanner.prototype.setCookieConsent = function () {
78
78
  if (this.$acceptCookiesButton.getAttribute('data-cookie-types') === 'all') {
79
- this.$module.cookieBannerConfirmationMessageText.insertAdjacentHTML('afterbegin', 'You have accepted additional cookies. ')
79
+ this.$module.querySelector('.gem-c-cookie-banner__confirmation-message__accepted').hidden = false
80
80
  }
81
81
  window.GOVUK.approveAllCookieTypes()
82
82
  this.$module.showConfirmationMessage()
@@ -92,7 +92,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
92
92
  }
93
93
 
94
94
  CookieBanner.prototype.rejectCookieConsent = function () {
95
- this.$module.cookieBannerConfirmationMessageText.insertAdjacentHTML('afterbegin', 'You have rejected additional cookies. ')
95
+ this.$module.querySelector('.gem-c-cookie-banner__confirmation-message__rejected').hidden = false
96
96
  this.$module.showConfirmationMessage()
97
97
  this.$module.cookieBannerConfirmationMessage.focus()
98
98
  window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
@@ -8,15 +8,5 @@ document.addEventListener('DOMContentLoaded', function () {
8
8
  window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {}
9
9
  window.GOVUK.analyticsVars = window.GOVUK.analyticsVars || {}
10
10
 
11
- // if statements ensure these functions don't execute during testing
12
- if (typeof window.GOVUK.loadAnalytics !== 'undefined') {
13
- if (typeof window.GOVUK.analyticsGa4.vars === 'undefined') {
14
- window.GOVUK.loadAnalytics.loadGa4()
15
- }
16
- if (typeof window.GOVUK.analyticsVars.gaProperty === 'undefined') {
17
- window.GOVUK.loadAnalytics.loadUa()
18
- }
19
- }
20
-
21
11
  window.GOVUK.modules.start()
22
12
  })
@@ -2,6 +2,8 @@
2
2
  //= require govuk_publishing_components/analytics-ga4
3
3
  //= require govuk_publishing_components/analytics/linked-domains
4
4
 
5
+ window.GOVUK = window.GOVUK || {}
6
+
5
7
  window.GOVUK.loadAnalytics = {
6
8
  productionDomains: [
7
9
  'www.gov.uk',
@@ -45,6 +47,7 @@ window.GOVUK.loadAnalytics = {
45
47
  },
46
48
 
47
49
  loadUa: function (currentDomain) {
50
+ // The domain can be overridden. This is needed for testing as we need to fake the domain that we are on to test each environment.
48
51
  currentDomain = currentDomain || window.location.hostname
49
52
 
50
53
  // Universal Analytics variables
@@ -54,13 +57,13 @@ window.GOVUK.loadAnalytics = {
54
57
  window.GOVUK.analyticsVars.gaProperty = 'UA-UNSET'
55
58
  window.GOVUK.analyticsVars.gaPropertyCrossDomain = 'UA-UNSET'
56
59
 
57
- if (this.arrayContains(currentDomain, this.productionDomains)) {
60
+ if (this.arrayContains({ valueToFind: currentDomain, array: this.productionDomains })) {
58
61
  window.GOVUK.analyticsVars.gaProperty = 'UA-26179049-1'
59
62
  window.GOVUK.analyticsVars.gaPropertyCrossDomain = 'UA-145652997-1'
60
- } else if (this.arrayContains(currentDomain, this.stagingDomains)) {
63
+ } else if (this.arrayContains({ valueToFind: currentDomain, array: this.stagingDomains })) {
61
64
  window.GOVUK.analyticsVars.gaProperty = 'UA-26179049-20'
62
65
  window.GOVUK.analyticsVars.gaPropertyCrossDomain = 'UA-145652997-1'
63
- } else if (this.arrayContains(currentDomain, this.integrationDomains)) {
66
+ } else if (this.arrayContains({ valueToFind: currentDomain, array: this.integrationDomains })) {
64
67
  window.GOVUK.analyticsVars.gaProperty = 'UA-26179049-22'
65
68
  window.GOVUK.analyticsVars.gaPropertyCrossDomain = 'UA-145652997-1'
66
69
  }
@@ -71,43 +74,136 @@ window.GOVUK.loadAnalytics = {
71
74
  }
72
75
  },
73
76
 
77
+ loadGa4Vars: function () {
78
+ // If we recognise the environment, load the GA4 vars
79
+ if (this.ga4EnvironmentVariables[this.environment]) {
80
+ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {}
81
+ window.GOVUK.analyticsGa4.vars = window.GOVUK.analyticsGa4.vars || {}
82
+ window.GOVUK.analyticsGa4.vars.id = 'GTM-MG7HG5W'
83
+ window.GOVUK.analyticsGa4.vars.auth = this.ga4EnvironmentVariables[this.environment].auth
84
+ window.GOVUK.analyticsGa4.vars.preview = this.ga4EnvironmentVariables[this.environment].preview
85
+ window.GOVUK.analyticsGa4.vars.environment = this.environment // Used for testing and debugging
86
+
87
+ window.GOVUK.analyticsGa4.vars.gem_version = 'not found'
88
+ var gemMeta = document.querySelector('meta[name="govuk:components_gem_version"]')
89
+ if (gemMeta) {
90
+ window.GOVUK.analyticsGa4.vars.gem_version = gemMeta.getAttribute('content')
91
+ }
92
+
93
+ window.GOVUK.analyticsGa4.vars.internalDomains = []
94
+ window.GOVUK.analyticsGa4.vars.internalDomains.push(window.GOVUK.analyticsGa4.core.trackFunctions.getHostname())
95
+ window.GOVUK.analyticsGa4.core.trackFunctions.appendDomainsWithoutWWW(window.GOVUK.analyticsGa4.vars.internalDomains)
96
+ }
97
+ },
98
+
99
+ addGtmScriptToDom: function () {
100
+ var firstScript = document.getElementsByTagName('script')[0]
101
+ var newScript = document.createElement('script')
102
+ newScript.async = true
103
+
104
+ // initialise GTM
105
+ window.dataLayer = window.dataLayer || []
106
+ window.dataLayer.push({ 'gtm.blocklist': ['customPixels', 'customScripts', 'html', 'nonGoogleScripts'] })
107
+ window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' })
108
+
109
+ var auth = window.GOVUK.analyticsGa4.vars.auth || ''
110
+ var preview = window.GOVUK.analyticsGa4.vars.preview || ''
111
+ if (auth) {
112
+ auth = '&gtm_auth=' + auth
113
+ }
114
+ if (preview) {
115
+ preview = '&gtm_preview=' + preview + '&gtm_cookies_win=x'
116
+ }
117
+
118
+ this.googleSrc = 'https://www.googletagmanager.com/gtm.js?id=' + window.GOVUK.analyticsGa4.vars.id + auth + preview
119
+ newScript.src = this.googleSrc
120
+ firstScript.parentNode.insertBefore(newScript, firstScript)
121
+ },
122
+
74
123
  loadGa4: function (currentDomain) {
124
+ // The domain can be overridden. This is needed for testing as we need to fake the domain that we are on to test each environment.
75
125
  currentDomain = currentDomain || window.location.hostname
76
- var environment = ''
77
126
 
127
+ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {}
128
+
129
+ if (typeof window.GOVUK.analyticsGa4.core === 'undefined') {
130
+ console.error('load-analytics.js: window.GOVUK.analyticsGa4.core was not found - has ./analytics-ga4.js been imported?')
131
+ return
132
+ }
133
+
134
+ this.environment = ''
78
135
  // Categorise current environment
79
- if (this.arrayContains(currentDomain, this.productionDomains)) {
80
- environment = 'production'
81
- } else if (this.arrayContains(currentDomain, this.stagingDomains)) {
82
- environment = 'staging'
83
- } else if (this.arrayContains(currentDomain, this.integrationDomains)) {
84
- environment = 'integration'
85
- } else if (this.arrayContains(currentDomain, this.developmentDomains) || currentDomain.indexOf('.dev.gov.uk') !== -1) {
86
- environment = 'development'
136
+ if (this.arrayContains({ valueToFind: currentDomain, array: this.productionDomains })) {
137
+ this.environment = 'production'
138
+ } else if (this.arrayContains({ valueToFind: currentDomain, array: this.stagingDomains })) {
139
+ this.environment = 'staging'
140
+ } else if (this.arrayContains({ valueToFind: currentDomain, array: this.integrationDomains })) {
141
+ this.environment = 'integration'
142
+ } else if (this.arrayContains({ valueToFind: currentDomain, array: this.developmentDomains }) || currentDomain.indexOf('.dev.gov.uk') !== -1) {
143
+ this.environment = 'development'
144
+ }
145
+
146
+ if (!this.environment) {
147
+ console.error('load-analytics.js: environment for GA4 not recognised - ' + this.environment + ' on ' + currentDomain)
148
+ return
149
+ }
150
+
151
+ // Don't load GA4 if initialiseGA4 is set to false. This allows us to disable analytics if required.
152
+ if (!this.ga4EnvironmentVariables[this.environment].initialiseGA4) {
153
+ return
87
154
  }
88
155
 
89
- // If we recognise the environment (i.e. the string isn't empty), load in GA4
90
- if (environment) {
91
- // If analytics-ga4.js exists and our detected environment has 'initialiseGA4' set to true, load GA4.
92
- if (typeof window.GOVUK.analyticsGa4.init !== 'undefined' && this.ga4EnvironmentVariables[environment].initialiseGA4) {
93
- window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {}
94
- window.GOVUK.analyticsGa4.vars = window.GOVUK.analyticsGa4.vars || {}
95
- window.GOVUK.analyticsGa4.vars.id = 'GTM-MG7HG5W'
96
- window.GOVUK.analyticsGa4.vars.auth = this.ga4EnvironmentVariables[environment].auth
97
- window.GOVUK.analyticsGa4.vars.preview = this.ga4EnvironmentVariables[environment].preview
98
- window.GOVUK.analyticsGa4.vars.environment = environment // Used for testing and debugging
99
-
100
- window.GOVUK.analyticsGa4.vars.gem_version = 'not found'
101
- var gemMeta = document.querySelector('meta[name="govuk:components_gem_version"]')
102
- if (gemMeta) {
103
- window.GOVUK.analyticsGa4.vars.gem_version = gemMeta.getAttribute('content')
156
+ // to be added: digital identity consent mechanism
157
+ var consentCookie = window.GOVUK.getConsentCookie()
158
+ if (consentCookie && consentCookie.usage) {
159
+ // Creates 'window.GOVUK.analyticsGa4.vars', then adds the gtm.js script to the DOM.
160
+ window.GOVUK.loadAnalytics.loadGa4Vars()
161
+ window.GOVUK.loadAnalytics.addGtmScriptToDom()
162
+
163
+ /* Initialises our GA4 modules once the DOM has loaded.
164
+ document.readyState is needed as when cookies aren't set the DOM is likely already loaded.
165
+ Therefore, if they accept cookies after the page has loaded our modules wouldn't initialise,
166
+ as DOMContentLoaded won't fire if the DOM has already loaded. */
167
+ if (document.readyState === 'complete') {
168
+ window.GOVUK.loadAnalytics.startGa4Modules()
169
+ } else {
170
+ window.addEventListener('DOMContentLoaded', function () {
171
+ window.GOVUK.loadAnalytics.startGa4Modules()
172
+ })
173
+ }
174
+
175
+ // to be added: cross domain tracking code
176
+ } else {
177
+ window.addEventListener('cookie-consent', function (e) {
178
+ window.GOVUK.loadAnalytics.loadGa4()
179
+ })
180
+ }
181
+ },
182
+
183
+ startGa4Modules: function () {
184
+ // Some tests initialise GA4, but we do not want our modules initialising, so this check is in place.
185
+ if (!window.GOVUK.analyticsGa4.vars.disableModules) {
186
+ var analyticsModules = window.GOVUK.analyticsGa4.analyticsModules
187
+ for (var property in analyticsModules) {
188
+ var module = analyticsModules[property]
189
+ if (typeof module.init === 'function') {
190
+ module.init()
104
191
  }
105
- window.GOVUK.analyticsGa4.init()
106
192
  }
107
193
  }
108
194
  },
109
195
 
110
- arrayContains: function (valueToFind, array) {
111
- return array.indexOf(valueToFind) !== -1
196
+ arrayContains: function (params) {
197
+ if (!params || !params.valueToFind || !params.array) {
198
+ return false
199
+ }
200
+
201
+ return params.array.indexOf(params.valueToFind) !== -1
112
202
  }
113
203
  }
204
+
205
+ // This if statement stops this function running during testing
206
+ if (!window.jasmine) {
207
+ window.GOVUK.loadAnalytics.loadUa()
208
+ window.GOVUK.loadAnalytics.loadGa4()
209
+ }
@@ -38,8 +38,13 @@
38
38
  if (typeof GOVUK.Modules[moduleName] === 'function' && !started) {
39
39
  // Vanilla JavaScript GOV.UK Modules and GOV.UK Frontend Modules
40
40
  if (GOVUK.Modules[moduleName].prototype.init) {
41
- new GOVUK.Modules[moduleName](element).init()
42
- element.setAttribute('data-' + moduleNames[j] + '-module-started', true)
41
+ try {
42
+ new GOVUK.Modules[moduleName](element).init()
43
+ element.setAttribute('data-' + moduleNames[j] + '-module-started', true)
44
+ } catch (e) {
45
+ // if there's a problem with the module, catch the error to allow other modules to start
46
+ console.error('Error starting ' + moduleName + ' component JS: ' + e.message, window.location)
47
+ }
43
48
  }
44
49
  }
45
50
  }
@@ -14,9 +14,9 @@
14
14
  text = raw(text)
15
15
 
16
16
  cookie_preferences_href ||= "/help/cookies"
17
- confirmation_message ||= raw(t("components.cookie_banner.confirmation_message_html",
17
+ confirmation_message ||= raw(t("components.cookie_banner.confirmation_message.html",
18
18
  link: link_to(
19
- t("components.cookie_banner.confirmation_message_link"),
19
+ t("components.cookie_banner.confirmation_message.link"),
20
20
  cookie_preferences_href,
21
21
  class: "govuk-link",
22
22
  data: {
@@ -79,13 +79,17 @@
79
79
  "track-action": "Cookie banner rejected",
80
80
  }
81
81
  } %>
82
- <a class="govuk-link" href="<%= cookie_preferences_href %>">View cookies</a>
82
+ <a class="govuk-link" href="<%= cookie_preferences_href %>"><%= t("components.cookie_banner.buttons.view_cookies") %></a>
83
83
  </div>
84
84
  <% end %>
85
85
  </div>
86
86
  </div>
87
87
  <div class="gem-c-cookie-banner__confirmation govuk-width-container" tabindex="-1" hidden>
88
- <p class="gem-c-cookie-banner__confirmation-message" role="alert"><%= confirmation_message %></p>
88
+ <p class="gem-c-cookie-banner__confirmation-message" role="alert">
89
+ <span class="gem-c-cookie-banner__confirmation-message__accepted" hidden><%= t("components.cookie_banner.confirmation_message.accepted") %>. </span>
90
+ <span class="gem-c-cookie-banner__confirmation-message__rejected" hidden><%= t("components.cookie_banner.confirmation_message.rejected") %>. </span>
91
+ <%= confirmation_message %>
92
+ </p>
89
93
  <div class="govuk-button-group">
90
94
  <button class="gem-c-cookie-banner__hide-button govuk-button" data-hide-cookie-banner="true" data-module="gem-track-click" data-track-category="cookieBanner" data-track-action="Hide cookie banner"><%= t("components.cookie_banner.hide") %></button>
91
95
  </div>
@@ -26,7 +26,7 @@
26
26
  extra_link_classes << brand_helper.color_class
27
27
 
28
28
  data_modules = %w[]
29
- data_modules << "gem-track-click" if card_helper.is_tracking?
29
+ data_modules << "gem-track-click ga4-link-tracker" if card_helper.is_tracking?
30
30
  data_modules << "image-card" if card_helper.youtube_video_id
31
31
  %>
32
32
  <% if card_helper.href || card_helper.extra_details.any? %>
@@ -58,6 +58,9 @@
58
58
  "lux-reporter-script": path_to_javascript("govuk_publishing_components/vendor/lux/lux-reporter")
59
59
  }
60
60
  } %>
61
+
62
+ <% # Used for Google Analytics 4 debugging. Must be placed before load-analytics script. %>
63
+ <meta name="govuk:components_gem_version" content="<%= GovukPublishingComponents::VERSION %>" />
61
64
  <%= javascript_include_tag "govuk_publishing_components/load-analytics" %>
62
65
 
63
66
  <%= csrf_meta_tags %>
@@ -79,9 +82,6 @@
79
82
  <% # The default og:image is added below :head so that scrapers see any custom metatags first, and this is just a fallback %>
80
83
  <meta property="og:image" content="<%= asset_path "govuk-opengraph-image.png" %>">
81
84
 
82
- <% # Used for Google Analytics 4 debugging %>
83
- <meta name="govuk:components_gem_version" content="<%= GovukPublishingComponents::VERSION %>" />
84
-
85
85
  <%= yield :head %>
86
86
  </head>
87
87
  <%= tag.body class: body_css_classes do %>
@@ -14,8 +14,14 @@
14
14
  show_search_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.show", :label => "search")
15
15
  hide_navigation_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.hide", :label => "navigation")
16
16
  show_navigation_menu_text = t("components.layout_super_navigation_header.menu_toggle_label.show", :label => "navigation")
17
+
18
+ navigation_links_length = 1 # GOVUK Logo makes this start from 1
19
+ navigation_links_columns.each do | column |
20
+ navigation_links_length = navigation_links_length + column[:menu_contents].length
21
+ end
22
+ navigation_links_length = navigation_links_length + popular_links.length
17
23
  %>
18
- <header role="banner" class="gem-c-layout-super-navigation-header" data-module="gem-track-click ga4-event-tracker" data-track-links-only data-ga4-expandable>
24
+ <header role="banner" class="gem-c-layout-super-navigation-header" data-module="gem-track-click ga4-event-tracker ga4-link-tracker" data-track-links-only data-ga4-expandable>
19
25
  <div class="gem-c-layout-super-navigation-header__container govuk-width-container govuk-clearfix">
20
26
  <div class="gem-c-layout-super-navigation-header__header-logo">
21
27
  <a
@@ -28,6 +34,15 @@
28
34
  href="<%= logo_link %>"
29
35
  id="logo"
30
36
  title="<%= logo_link_title %>"
37
+ data-ga4-link="<%= {
38
+ "event_name": "navigation",
39
+ "type": "header menu bar",
40
+ "external": "false",
41
+ "text": "GOV.UK",
42
+ "section": "Logo",
43
+ "index": 0,
44
+ "index_total": navigation_links_length
45
+ }.to_json %>"
31
46
  >
32
47
  <span class="govuk-header__logotype">
33
48
  <!--[if gt IE 8]><!-->
@@ -125,7 +140,7 @@
125
140
  <div class="gem-c-layout-super-navigation-header__width-container">
126
141
  <div class="govuk-grid-row">
127
142
 
128
- <% navigation_links_columns.each_with_index do | column, index | %>
143
+ <% navigation_links_columns.each_with_index do | column, column_index | %>
129
144
  <%
130
145
  case column[:size]
131
146
  when 2
@@ -142,7 +157,7 @@
142
157
  <%= column[:label] %>
143
158
  </h3>
144
159
  <ul class="gem-c-layout-super-navigation-header__navigation-second-items gem-c-layout-super-navigation-header__navigation-second-items--<%= column[:label].downcase.sub(" ", "-") %>">
145
- <% column[:menu_contents].each do | item | %>
160
+ <% column[:menu_contents].each_with_index do | item, index | %>
146
161
  <%
147
162
  has_description = item[:description].present?
148
163
  link_classes = %w[govuk-link gem-c-layout-super-navigation-header__navigation-second-item-link]
@@ -158,6 +173,13 @@
158
173
  track_label: item[:href],
159
174
  track_dimension: item[:label],
160
175
  track_dimension_index: "29",
176
+ ga4_link: {
177
+ "event_name": "navigation",
178
+ "type": "header menu bar",
179
+ "index": "1.#{column_index + 1}.#{index + 1}",
180
+ "index_total": navigation_links_length,
181
+ "section": column[:label],
182
+ }
161
183
  }
162
184
  } %>
163
185
  <%= tag.p item[:description], class: "gem-c-layout-super-navigation-header__navigation-second-item-description" if has_description %>
@@ -279,7 +301,7 @@
279
301
  <div class="govuk-grid-column-full">
280
302
  <h3 class="govuk-heading-m"><%= popular_links_heading %></h3>
281
303
  <ul class="govuk-list">
282
- <% popular_links.each do | popular_link | %>
304
+ <% popular_links.each_with_index do | popular_link, index | %>
283
305
  <li class="gem-c-layout-super-navigation-header__popular-item">
284
306
  <%= link_to popular_link[:label], popular_link[:href], {
285
307
  class: [
@@ -292,6 +314,13 @@
292
314
  track_label: popular_link[:href],
293
315
  track_dimension: popular_link[:label],
294
316
  track_dimension_index: "29",
317
+ ga4_link: {
318
+ "event_name": "navigation",
319
+ "type": "header menu bar",
320
+ "index": "2.2.#{index + 1}",
321
+ "index_total": navigation_links_length,
322
+ "section": popular_links_heading,
323
+ }
295
324
  }
296
325
  } %>
297
326
  </li>
@@ -44,8 +44,12 @@ ar:
44
44
  buttons:
45
45
  accept_cookies: قبول ملفات تعريف الارتباط الإضافية
46
46
  reject_cookies: رفض ملفات تعريف الارتباط الإضافية
47
- confirmation_message_html: يمكنك %{link} في أي وقت.
48
- confirmation_message_link: قم بتغيير إعدادات ملفات تعريف الارتباط الخاصة بك
47
+ view_cookies:
48
+ confirmation_message:
49
+ accepted:
50
+ html: يمكنك %{link} في أي وقت.
51
+ link: قم بتغيير إعدادات ملفات تعريف الارتباط الخاصة بك
52
+ rejected:
49
53
  hide: إخفاء هذه الرسالة
50
54
  text:
51
55
  - نحن نستخدم بعض ملفات تعريف الارتباط الأساسية لجعل هذا الموقع يعمل.
@@ -40,8 +40,12 @@ az:
40
40
  buttons:
41
41
  accept_cookies: Əlavə kukilər qəbul edin
42
42
  reject_cookies: Əlavə kukilərdən imtina edin
43
- confirmation_message_html: İstənilən vaxt %{link}.
44
- confirmation_message_link: Kuki parametrlərinizi dəyişdirin
43
+ view_cookies:
44
+ confirmation_message:
45
+ accepted:
46
+ html: İstənilən vaxt %{link}.
47
+ link: Kuki parametrlərinizi dəyişdirin
48
+ rejected:
45
49
  hide: Bu mesajı gizlət
46
50
  text:
47
51
  - Biz bu vebsaytın işləməsini təmin etmək üçün bəzi zəruri kukilərdən istifadə edirik.
@@ -42,8 +42,12 @@ be:
42
42
  buttons:
43
43
  accept_cookies: Прыняць дадатковыя файлы cookie
44
44
  reject_cookies: Адхіліць дадатковыя файлы cookie
45
- confirmation_message_html: Вы можаце %{link} у любы час.
46
- confirmation_message_link: змяніць налады файлаў cookie
45
+ view_cookies:
46
+ confirmation_message:
47
+ accepted:
48
+ html: Вы можаце %{link} у любы час.
49
+ link: змяніць налады файлаў cookie
50
+ rejected:
47
51
  hide: Схаваць гэта паведамленне
48
52
  text:
49
53
  - Мы выкарыстоўваем некаторыя асноўныя файлы cookie для забеспячэння працы гэтага сайта.
@@ -40,8 +40,12 @@ bg:
40
40
  buttons:
41
41
  accept_cookies: Приемане на допълнителни бисквитки
42
42
  reject_cookies: Отказване от допълнителни бисквитки
43
- confirmation_message_html: Можете да %{link} по всяко време.
44
- confirmation_message_link: Промяна на настройките за бисквитките
43
+ view_cookies:
44
+ confirmation_message:
45
+ accepted:
46
+ html: Можете да %{link} по всяко време.
47
+ link: Промяна на настройките за бисквитките
48
+ rejected:
45
49
  hide: Скриване на това съобщение
46
50
  text:
47
51
  - Използваме някои основни бисквитки
@@ -40,8 +40,12 @@ bn:
40
40
  buttons:
41
41
  accept_cookies: অতিরিক্ত কুকিজ গ্রহণ করুন
42
42
  reject_cookies: অতিরিক্ত কুকিজ প্রত্যাখ্যান করুন
43
- confirmation_message_html: আপনি যেকোনো সময় %{link} করতে পারেন।
44
- confirmation_message_link: আপনার কুকি সেটিংস পরিবর্তন করুন
43
+ view_cookies:
44
+ confirmation_message:
45
+ accepted:
46
+ html: আপনি যেকোনো সময় %{link} করতে পারেন।
47
+ link: আপনার কুকি সেটিংস পরিবর্তন করুন
48
+ rejected:
45
49
  hide: এই মেসেজটি লুকিয়ে রাখুন
46
50
  text:
47
51
  - "“এই ওয়েবসাইটটি যেন কাজ করে সেজন্য আমরা কিছু প্রয়োজনীয় কুকি ব্যবহার করি”"
@@ -41,8 +41,12 @@ cs:
41
41
  buttons:
42
42
  accept_cookies: Přijmout další soubory cookie
43
43
  reject_cookies: Odmítnutí dalších souborů cookie
44
- confirmation_message_html: Kdykoli můžete %{link}.
45
- confirmation_message_link: Změna nastavení souborů cookie
44
+ view_cookies:
45
+ confirmation_message:
46
+ accepted:
47
+ html: Kdykoli můžete %{link}.
48
+ link: Změna nastavení souborů cookie
49
+ rejected:
46
50
  hide: Skrýt tuto zprávu
47
51
  text:
48
52
  - Používáme některé základní soubory cookie
@@ -44,8 +44,12 @@ cy:
44
44
  buttons:
45
45
  accept_cookies: Derbyn cwcis ychwanegol
46
46
  reject_cookies: Gwrthod cwcis ychwanegol
47
- confirmation_message_html: Gallwch %{link} unrhyw bryd.
48
- confirmation_message_link: newid eich gosodiadau cwcis
47
+ view_cookies:
48
+ confirmation_message:
49
+ accepted:
50
+ html: Gallwch %{link} unrhyw bryd.
51
+ link: newid eich gosodiadau cwcis
52
+ rejected:
49
53
  hide: Cuddio'r neges hon
50
54
  text:
51
55
  - Rydyn ni'n defnyddio rhai cwcis hanfodol i wneud i'r wefan hon weithio.
@@ -40,8 +40,12 @@ da:
40
40
  buttons:
41
41
  accept_cookies: Accepter yderligere cookies
42
42
  reject_cookies: Afvise yderligere cookies
43
- confirmation_message_html: Du kan %{link} når som helst.
44
- confirmation_message_link: ændre dine cookie-indstillinger
43
+ view_cookies:
44
+ confirmation_message:
45
+ accepted:
46
+ html: Du kan %{link} når som helst.
47
+ link: ændre dine cookie-indstillinger
48
+ rejected:
45
49
  hide: Skjul denne meddelelse
46
50
  text:
47
51
  - Vi bruger nogle vigtige cookies for at få dette websted til at fungere.
@@ -40,8 +40,12 @@ de:
40
40
  buttons:
41
41
  accept_cookies: Zusätzliche Cookies akzeptieren
42
42
  reject_cookies: Zusätzliche Cookies ablehnen
43
- confirmation_message_html: Sie können jederzeit %{link}.
44
- confirmation_message_link: Cookie-Einstellungen ändern
43
+ view_cookies:
44
+ confirmation_message:
45
+ accepted:
46
+ html: Sie können jederzeit %{link}.
47
+ link: Cookie-Einstellungen ändern
48
+ rejected:
45
49
  hide: Diese Meldung ausblenden
46
50
  text:
47
51
  - Wir verwenden einige essenzielle Cookies
@@ -43,8 +43,12 @@ dr:
43
43
  buttons:
44
44
  accept_cookies: کوکی هایی اضافی را بپذیرید
45
45
  reject_cookies: کوکی هایی اضافی را رد نمایید
46
- confirmation_message_html: در هر زمان میتوانید %{link} کنید.
47
- confirmation_message_link: تنظیمات کوکی خودرا تغییر دهید
46
+ view_cookies:
47
+ confirmation_message:
48
+ accepted:
49
+ html: در هر زمان میتوانید %{link} کنید.
50
+ link: تنظیمات کوکی خودرا تغییر دهید
51
+ rejected:
48
52
  hide: این پیام را مخفی نمایید
49
53
  text:
50
54
  - ما از برخی کوکی هایی ضروری برای اینکه این ویبسایت کار نماید استفاده میکنیم.
@@ -40,8 +40,12 @@ el:
40
40
  buttons:
41
41
  accept_cookies: Αποδοχή επιπλέον cookies
42
42
  reject_cookies: Απόρριψη επιπλέον cookies
43
- confirmation_message_html: Μπορείτε %{link} ανά πάσα στιγμή.
44
- confirmation_message_link: αλλάξτε τις ρυθμίσεις cookies
43
+ view_cookies:
44
+ confirmation_message:
45
+ accepted:
46
+ html: Μπορείτε %{link} ανά πάσα στιγμή.
47
+ link: αλλάξτε τις ρυθμίσεις cookies
48
+ rejected:
45
49
  hide: Απόκρυψη αυτού του μηνύματος
46
50
  text:
47
51
  - Χρησιμοποιούμε μερικά βασικά cookies για να λειτουργήσει αυτός ο ιστότοπος.