govuk_publishing_components 30.6.1 → 30.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06ca4d601d0b03adb4b547798eaffae4455c9fa854e97172bce34fe6164cbd2f
4
- data.tar.gz: 7cb234f6d40408729f077a5c5faacf7d878300fca110d5d56847e7efeee78dcc
3
+ metadata.gz: 5541caeb04840db83172565a1e2f4f8f572850a113132c5e67d3d46ab00caf1e
4
+ data.tar.gz: 81d4933ed8632f6bcc89a575a7a208e4575b7a842d0aa844bbfce317a69de9f9
5
5
  SHA512:
6
- metadata.gz: bf986be244673e1346c95d129993a51beea17104ff5e2deba9e454f3eb4299d2c4961651e8a5fe1fde162bf95348024d72cc58465f81fb8bda7466cd2d3ea42c
7
- data.tar.gz: 6c1b7d356bf4cf208ca53379b26c07e1b815f0324a5a5ad16be3762c0388c497a7a4b5737df73e0b4bb9775979a81ab255a8b2b8a1da978b1c7b5a4b39cef610
6
+ metadata.gz: 6f8eea00f619818ebbbf6f83a3ffcb63b7d06c62dda8f45aab579f2b13ae363864ff8dbd4cabdcdac331e1fa95174660a9709e845b972aa06c6be8c9f550d439
7
+ data.tar.gz: da2bb07ca8ab25c753f29af58965afb1dea0cfd781f57e7aea2129fce4a26db90346858341f7d9ba7adb572b5f7867db3a45586d487b56b5b98e151d9932d21b
@@ -0,0 +1,141 @@
1
+ // = require govuk/vendor/polyfills/Element/prototype/closest.js
2
+ ;(function (global) {
3
+ 'use strict'
4
+
5
+ var GOVUK = global.GOVUK || {}
6
+ GOVUK.analyticsGA4 = GOVUK.analyticsGA4 || {}
7
+
8
+ GOVUK.analyticsGA4.Ga4EnhancedEcommerceTracker = {
9
+ PIIRemover: new GOVUK.analyticsGA4.PIIRemover(),
10
+ DEFAULT_LIST_TITLE: 'Site search results',
11
+
12
+ init: function (isNewPageLoad) {
13
+ if (window.dataLayer) {
14
+ this.searchResultsBlocks = document.querySelectorAll('[data-ga4-ecommerce]')
15
+ this.isNewPageLoad = isNewPageLoad
16
+
17
+ if (!this.searchResultsBlocks.length === 0) {
18
+ return
19
+ }
20
+
21
+ /* If the results are updated by JS, the URL of the page will change and this needs to be visible to PA's,
22
+ hence the pageView object push to the dataLayer. We do not need to send a pageView object on page load as
23
+ this is handled elsewhere. */
24
+ if (!this.isNewPageLoad) {
25
+ var pageViewTracker = window.GOVUK.analyticsGA4.analyticsModules.PageViewTracker
26
+
27
+ if (pageViewTracker) {
28
+ pageViewTracker.init()
29
+ }
30
+ }
31
+
32
+ for (var i = 0; i < this.searchResultsBlocks.length; i++) {
33
+ this.trackSearchResults(this.searchResultsBlocks[i])
34
+
35
+ if (this.isNewPageLoad) {
36
+ this.searchResultsBlocks[i].addEventListener('click', this.handleClick.bind(this))
37
+ }
38
+ }
39
+ }
40
+ },
41
+
42
+ trackSearchResults: function (searchResultsBlock) {
43
+ var schema = this.populateEcommerceSchema(searchResultsBlock, false, null)
44
+
45
+ this.clearPreviousEcommerceObject()
46
+ window.dataLayer.push(schema)
47
+ },
48
+
49
+ handleClick: function (event) {
50
+ var searchResultsBlock = event.target.closest('[data-ga4-ecommerce]')
51
+ var isSearchResult = event.target.getAttribute('data-ecommerce-path')
52
+
53
+ if (isSearchResult) {
54
+ var searchResult = event.target
55
+ var schema = this.populateEcommerceSchema(searchResultsBlock, true, searchResult)
56
+
57
+ this.clearPreviousEcommerceObject()
58
+ window.dataLayer.push(schema)
59
+ }
60
+ },
61
+
62
+ populateEcommerceSchema: function (searchResultsBlock, searchResultClicked, searchResult) {
63
+ // Limiting to 100 characters to avoid noise from extra long search queries and to stop the size of the payload going over 8k limit.
64
+ var searchQuery = this.PIIRemover.stripPII(searchResultsBlock.getAttribute('data-search-query')).substring(0, 100).toLowerCase()
65
+ var variant = searchResultsBlock.getAttribute('data-ecommerce-variant') || undefined
66
+ var ecommerceRows = searchResultsBlock.querySelectorAll('[data-ecommerce-row]')
67
+ var listTitle = searchResultsBlock.getAttribute('data-list-title') || this.DEFAULT_LIST_TITLE
68
+ var startPosition = parseInt(searchResultsBlock.getAttribute('data-ecommerce-start-index'), 10)
69
+
70
+ var ecommerceObject = {
71
+ event: 'search_results',
72
+ search_results: {
73
+ event_name: searchResultClicked && searchResult ? 'select_item' : 'view_item_list',
74
+ term: searchQuery,
75
+ sort: variant,
76
+ results: this.getResultsCount(searchResultsBlock),
77
+ ecommerce: {
78
+ items: []
79
+ }
80
+ }
81
+ }
82
+
83
+ // Populate items array
84
+ if (searchResultClicked && searchResult) {
85
+ ecommerceObject.search_results.ecommerce.items.push({
86
+ item_id: searchResult.getAttribute('data-ecommerce-path'),
87
+ item_name: searchResult.textContent,
88
+ item_list_name: listTitle,
89
+ index: this.getIndex(searchResult, startPosition)
90
+ })
91
+
92
+ ecommerceObject.event_data = {
93
+ external: GOVUK.analyticsGA4.analyticsModules.Ga4LinkTracker.isExternalLink(searchResult.getAttribute('data-ecommerce-path')) ? 'true' : 'false'
94
+ }
95
+ } else {
96
+ for (var i = 0; i < ecommerceRows.length; i++) {
97
+ var ecommerceRow = ecommerceRows[i]
98
+ var path = ecommerceRow.getAttribute('data-ecommerce-path')
99
+
100
+ /* If the element does not have a data-ecommerce-index attribute, we set one so that we can use it later when setting the index property
101
+ on the ecommerce object. This for loop will always run on page load and so data-ecommerce-index will be available when we use it in the
102
+ initial if block above that checks if a search result has been clicked. */
103
+ if (!ecommerceRow.getAttribute('data-ecommerce-index')) {
104
+ ecommerceRow.setAttribute('data-ecommerce-index', i + 1)
105
+ }
106
+
107
+ ecommerceObject.search_results.ecommerce.items.push({
108
+ item_id: path,
109
+ item_list_name: listTitle,
110
+ index: this.getIndex(ecommerceRow, startPosition)
111
+ })
112
+ }
113
+ }
114
+
115
+ return ecommerceObject
116
+ },
117
+
118
+ getIndex: function (element, startPosition) {
119
+ return parseInt(element.getAttribute('data-ecommerce-index')) + startPosition - 1
120
+ },
121
+
122
+ clearPreviousEcommerceObject: function () {
123
+ window.dataLayer.push({ search_results: { ecommerce: null } })
124
+ },
125
+
126
+ getResultsCount: function (searchResultsBlock) {
127
+ // This returns a string e.g. '12,345 results'. Therefore to extract the number, we need to remove the comma and split the string at the space
128
+ var resultsCount = searchResultsBlock.querySelector('#js-result-count')
129
+
130
+ if (!resultsCount) {
131
+ return null
132
+ }
133
+
134
+ resultsCount = resultsCount.textContent.replace(',', '')
135
+ resultsCount = resultsCount.split(' ')[0]
136
+ return parseInt(resultsCount)
137
+ }
138
+ }
139
+
140
+ global.GOVUK = GOVUK
141
+ })(window)
@@ -7,15 +7,23 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
7
7
  'use strict'
8
8
 
9
9
  var Ga4LinkTracker = {
10
- init: function () {
10
+ init: function (config) {
11
11
  if (window.dataLayer) {
12
- this.internalLinksDomain = 'www.gov.uk/'
13
- this.internalLinksDomainWithoutWww = 'gov.uk/'
12
+ config = config || {}
13
+ this.internalDomains = config.internalDomains || []
14
+ this.internalDomains.push(this.getHostname())
15
+ this.appendDomainsWithoutWWW(this.internalDomains)
16
+ this.internalDownloadPaths = config.internalDownloadPaths || ['/government/uploads/']
17
+ this.dedicatedDownloadDomains = config.dedicatedDownloadDomains || ['assets.publishing.service.gov.uk']
18
+ this.appendDomainsWithoutWWW(this.dedicatedDownloadDomains)
14
19
  this.handleClick = this.handleClick.bind(this)
15
20
  this.handleMousedown = this.handleMousedown.bind(this)
16
- document.querySelector('body').addEventListener('click', this.handleClick)
17
- document.querySelector('body').addEventListener('contextmenu', this.handleClick)
18
- document.querySelector('body').addEventListener('mousedown', this.handleMousedown)
21
+
22
+ if (!config.disableListeners) {
23
+ document.querySelector('body').addEventListener('click', this.handleClick)
24
+ document.querySelector('body').addEventListener('contextmenu', this.handleClick)
25
+ document.querySelector('body').addEventListener('mousedown', this.handleMousedown)
26
+ }
19
27
  }
20
28
  },
21
29
 
@@ -43,25 +51,52 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
43
51
  return
44
52
  }
45
53
 
46
- if (this.isMailToLink(href)) {
54
+ var linkAttributes = element.getAttribute('data-ga4-link')
55
+ if (linkAttributes) {
56
+ linkAttributes = JSON.parse(linkAttributes)
57
+ clickData = window.GOVUK.extendObject(clickData, linkAttributes)
58
+
59
+ /* Since external links can't be determined in the template, we use populated-via-js as a signal
60
+ for our JavaScript to determine this value. */
61
+ if (clickData.external === 'populated-via-js' && clickData.url) {
62
+ clickData.external = this.isExternalLink(clickData.url) ? 'true' : 'false'
63
+ }
64
+
65
+ if (clickData.link_method === 'populated-via-js') {
66
+ clickData.link_method = this.getClickType(event)
67
+ }
68
+
69
+ if (clickData.index) {
70
+ clickData.index = parseInt(linkAttributes.index)
71
+ }
72
+
73
+ if (clickData.index_total) {
74
+ clickData.index_total = parseInt(linkAttributes.index_total)
75
+ }
76
+ } else if (this.isMailToLink(href)) {
47
77
  clickData.event_name = 'navigation'
48
78
  clickData.type = 'email'
49
79
  clickData.external = 'true'
80
+ clickData.url = href
81
+ clickData.text = element.textContent.trim()
82
+ clickData.link_method = this.getClickType(event)
50
83
  } else if (this.isDownloadLink(href)) {
51
84
  clickData.event_name = 'file_download'
52
85
  clickData.type = this.isPreviewLink(href) ? 'preview' : 'generic download'
53
- clickData.external = 'true'
86
+ clickData.external = this.isExternalLink(href) ? 'true' : 'false'
87
+ clickData.url = href
88
+ clickData.text = element.textContent.trim()
89
+ clickData.link_method = this.getClickType(event)
54
90
  } else if (this.isExternalLink(href)) {
55
91
  clickData.event_name = 'navigation'
56
92
  clickData.type = 'generic link'
57
93
  clickData.external = 'true'
58
- }
59
-
60
- if (Object.keys(clickData).length > 0) {
61
- clickData.text = element.textContent.trim()
62
94
  clickData.url = href
95
+ clickData.text = element.textContent.trim()
63
96
  clickData.link_method = this.getClickType(event)
97
+ }
64
98
 
99
+ if (Object.keys(clickData).length > 0) {
65
100
  var schema = new window.GOVUK.analyticsGA4.Schemas().eventSchema()
66
101
  schema.event = 'event_data'
67
102
 
@@ -77,6 +112,17 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
77
112
  }
78
113
  },
79
114
 
115
+ appendDomainsWithoutWWW: function (domainsArrays) {
116
+ // Add domains with www. removed, in case site hrefs are marked up without www. included.
117
+ for (var i = 0; i < domainsArrays.length; i++) {
118
+ var domain = domainsArrays[i]
119
+ if (this.stringStartsWith(domain, 'www.')) {
120
+ var domainWithoutWww = domain.replace('www.', '')
121
+ domainsArrays.push(domainWithoutWww)
122
+ }
123
+ }
124
+ },
125
+
80
126
  getClickType: function (event) {
81
127
  switch (event.type) {
82
128
  case 'click':
@@ -84,6 +130,8 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
84
130
  return 'ctrl click'
85
131
  } else if (event.metaKey) {
86
132
  return 'command/win click'
133
+ } else if (event.shiftKey) {
134
+ return 'shift click'
87
135
  } else {
88
136
  return 'primary click'
89
137
  }
@@ -106,29 +154,36 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
106
154
  },
107
155
 
108
156
  isDownloadLink: function (href) {
109
- var assetsDomain = 'assets.publishing.service.gov.uk/'
110
- var uploadsPath = '/government/uploads/'
111
-
112
- if (this.hrefPointsToDomain(href, assetsDomain)) {
157
+ if (this.isInternalLink(href) && this.hrefPointsToDownloadPath(href)) {
113
158
  return true
114
159
  }
115
160
 
116
- var isInternalLink = this.hrefPointsToDomain(href, this.internalLinksDomain) || this.hrefPointsToDomain(href, this.internalLinksDomainWithoutWww)
117
- if (isInternalLink && href.indexOf(uploadsPath) !== -1) {
118
- return true
161
+ var result = false
162
+ for (var i = 0; i < this.dedicatedDownloadDomains.length; i++) {
163
+ var downloadDomain = this.dedicatedDownloadDomains[i]
164
+ if (this.hrefPointsToDomain(href, downloadDomain)) {
165
+ result = true
166
+ }
119
167
  }
168
+ return result
169
+ },
120
170
 
121
- // Checks relative links to the uploadsPath
122
- if (this.stringStartsWith(href, uploadsPath)) {
171
+ isInternalLink: function (href) {
172
+ if (this.hrefIsRelative(href) || this.hrefIsAnchor(href)) {
123
173
  return true
124
174
  }
175
+ var result = false
176
+ for (var i = 0; i < this.internalDomains.length; i++) {
177
+ var internalDomain = this.internalDomains[i]
178
+ if (this.hrefPointsToDomain(href, internalDomain)) {
179
+ result = true
180
+ }
181
+ }
182
+ return result
125
183
  },
126
184
 
127
185
  isExternalLink: function (href) {
128
- var isInternalLink = this.hrefPointsToDomain(href, this.internalLinksDomain) || this.hrefPointsToDomain(href, this.internalLinksDomainWithoutWww)
129
- if (!isInternalLink && !this.hrefIsRelative(href) && !this.hrefIsAnchor(href)) {
130
- return true
131
- }
186
+ return !this.isInternalLink(href)
132
187
  },
133
188
 
134
189
  isPreviewLink: function (href) {
@@ -144,6 +199,19 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
144
199
  },
145
200
 
146
201
  hrefPointsToDomain: function (href, domain) {
202
+ /* Add a trailing slash to prevent an edge case such
203
+ as the href www.gov.uk.domain.co.uk being detected as an internal link,
204
+ if we were checking for 'www.gov.uk' instead of 'www.gov.uk/' */
205
+ if (domain.substring(domain.length) !== '/') {
206
+ domain = domain + '/'
207
+ }
208
+
209
+ /* If the href doesn't end in a slash, we add one.
210
+ This fixes an edge case where the <a href> is exactly `https://www.gov.uk`
211
+ but these checks would only look for `https://www.gov.uk/` */
212
+ if (href.substring(href.length) !== '/') {
213
+ href = href + '/'
214
+ }
147
215
  var httpDomain = 'http://' + domain
148
216
  var httpsDomain = 'https://' + domain
149
217
  var schemaRelativeDomain = '//' + domain
@@ -153,6 +221,17 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
153
221
  this.stringStartsWith(href, schemaRelativeDomain)
154
222
  },
155
223
 
224
+ hrefPointsToDownloadPath: function (href) {
225
+ var result = false
226
+ for (var i = 0; i < this.internalDownloadPaths.length; i++) {
227
+ var internalDownloadPath = this.internalDownloadPaths[i]
228
+ if (href.indexOf(internalDownloadPath) !== -1) {
229
+ result = true
230
+ }
231
+ }
232
+ return result
233
+ },
234
+
156
235
  stringStartsWith: function (string, stringToFind) {
157
236
  return string.substring(0, stringToFind.length) === stringToFind
158
237
  },
@@ -164,6 +243,10 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
164
243
 
165
244
  hrefIsAnchor: function (href) {
166
245
  return href[0] === '#'
246
+ },
247
+
248
+ getHostname: function () {
249
+ return window.location.hostname
167
250
  }
168
251
  }
169
252
 
@@ -7,7 +7,7 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
7
7
 
8
8
  var PageViewTracker = {
9
9
  PIIRemover: new window.GOVUK.analyticsGA4.PIIRemover(), // imported in analytics-ga4.js
10
- nullValue: null,
10
+ nullValue: undefined,
11
11
 
12
12
  init: function () {
13
13
  if (window.dataLayer) {
@@ -102,7 +102,7 @@ window.GOVUK.analyticsGA4.analyticsModules = window.GOVUK.analyticsGA4.analytics
102
102
  // return only the date from given timestamps of the form
103
103
  // 2022-03-28T19:11:00.000+00:00
104
104
  stripTimeFrom: function (value) {
105
- if (value !== null) {
105
+ if (value !== undefined) {
106
106
  return value.split('T')[0]
107
107
  } else {
108
108
  return this.nullValue
@@ -4,24 +4,24 @@
4
4
  var GOVUK = global.GOVUK || {}
5
5
 
6
6
  var Schemas = function () {
7
- this.null = null
7
+ this.undefined = undefined
8
8
  }
9
9
 
10
10
  Schemas.prototype.eventSchema = function () {
11
11
  return {
12
- event: this.null,
12
+ event: this.undefined,
13
13
 
14
14
  event_data: {
15
- event_name: this.null,
16
- type: this.null,
17
- url: this.null,
18
- text: this.null,
19
- index: this.null,
20
- index_total: this.null,
21
- section: this.null,
22
- action: this.null,
23
- external: this.null,
24
- link_method: this.null
15
+ event_name: this.undefined,
16
+ type: this.undefined,
17
+ url: this.undefined,
18
+ text: this.undefined,
19
+ index: this.undefined,
20
+ index_total: this.undefined,
21
+ section: this.undefined,
22
+ action: this.undefined,
23
+ external: this.undefined,
24
+ link_method: this.undefined
25
25
  }
26
26
  }
27
27
  }
@@ -5,4 +5,5 @@
5
5
  //= require ./analytics-ga4/ga4-page-views
6
6
  //= require ./analytics-ga4/ga4-link-tracker
7
7
  //= require ./analytics-ga4/ga4-event-tracker
8
+ //= require ./analytics-ga4/ga4-enhanced-ecommerce-tracker
8
9
  //= require ./analytics-ga4/init-ga4
@@ -30,7 +30,10 @@
30
30
  _gid: 'usage',
31
31
  _gat: 'usage',
32
32
  'JS-Detection': 'usage',
33
- TLSversion: 'usage'
33
+ TLSversion: 'usage',
34
+ _ga_VBLT2V3FZR: 'usage', // gtag cookie used to persist the session state, integration
35
+ _ga_P1DGM6TVYF: 'usage', // staging
36
+ _ga_S5RQ7FTGVR: 'usage' // production
34
37
  }
35
38
 
36
39
  /*
@@ -8,7 +8,7 @@
8
8
  path_without_pii = utf_encode(request.fullpath.gsub(email_regex, '[email]'))
9
9
  %>
10
10
 
11
- <div class="gem-c-feedback govuk-!-display-none-print" data-module="feedback">
11
+ <div class="gem-c-feedback govuk-!-display-none-print" data-module="feedback ga4-event-tracker">
12
12
  <%= render "govuk_publishing_components/components/feedback/yes_no_banner" %>
13
13
  <%= render "govuk_publishing_components/components/feedback/problem_form", url_without_pii: url_without_pii %>
14
14
  <%= render "govuk_publishing_components/components/feedback/survey_signup_form", path_without_pii: path_without_pii %>
@@ -2,6 +2,7 @@
2
2
  links ||= []
3
3
  title ||= false
4
4
  track_as_sharing ||= false
5
+ track_as_follow ||= false
5
6
  stacked ||= false
6
7
  columns ||= false
7
8
 
@@ -23,7 +24,7 @@
23
24
  <% end %>
24
25
 
25
26
  <ul class="gem-c-share-links__list">
26
- <% links.each do |link| %>
27
+ <% links.each_with_index do |link, index| %>
27
28
  <% link_text = capture do %>
28
29
  <span class="govuk-visually-hidden">
29
30
  <% if link[:hidden_text] %>
@@ -42,6 +43,26 @@
42
43
  'socialNetwork': link[:icon],
43
44
  'socialTarget': link[:href]
44
45
  }
46
+ ga4_link_data = {
47
+ 'event_name': 'share',
48
+ 'type': 'share this page',
49
+ 'index': index + 1,
50
+ 'index_total': links.length,
51
+ 'text': link[:icon],
52
+ 'link_method': 'populated-via-js'
53
+ }
54
+ end
55
+ if track_as_follow
56
+ ga4_link_data = {
57
+ 'event_name': 'navigation',
58
+ 'type': 'follow us',
59
+ 'index': index + 1,
60
+ 'index_total': links.length,
61
+ 'text': link[:text],
62
+ 'external': 'populated-via-js',
63
+ 'url': link[:href],
64
+ 'link_method': 'populated-via-js'
65
+ }
45
66
  end
46
67
  %>
47
68
  <%= link_to link[:href],
@@ -50,7 +71,8 @@
50
71
  data: {
51
72
  'track-category': 'social media',
52
73
  'track-action': link[:icon],
53
- 'track-options': track_options
74
+ 'track-options': track_options,
75
+ 'ga4-link': ga4_link_data
54
76
  },
55
77
  class: "govuk-link govuk-link--no-underline gem-c-share-links__link #{brand_helper.color_class}" do %>
56
78
  <span class="gem-c-share-links__link-icon">
@@ -45,7 +45,7 @@ examples:
45
45
  context:
46
46
  right_to_left: true
47
47
  track_as_sharing_links:
48
- description: Where the component is used to allow users to share content on social media, tracking can be added that uses [Social Interactions](https://developers.google.com/analytics/devguides/collection/analyticsjs/social-interactions). If this option is not included, it is assumed the component is simply linking to social media pages and the extra options are omitted from the tracking call.
48
+ description: Where the component is used to allow users to share content on social media, tracking can be added that uses [Social Interactions](https://developers.google.com/analytics/devguides/collection/analyticsjs/social-interactions) in UA. If this option is not included, it is assumed the component is simply linking to social media pages and the extra options are omitted from the tracking call in UA. In GA4, when this is set to true, a JSON is added to a data-attribute called data-ga4-link, which is detected by ga4-link-tracker.js and pushed to the dataLayer.
49
49
  data:
50
50
  track_as_sharing: true
51
51
  links: [
@@ -53,7 +53,28 @@ examples:
53
53
  href: 'share',
54
54
  text: 'Share on Facebook',
55
55
  icon: 'facebook'
56
- }
56
+ },
57
+ {
58
+ href: 'share',
59
+ text: 'Share on Twitter',
60
+ icon: 'twitter'
61
+ },
62
+ ]
63
+ track_as_follow_links:
64
+ description: Where the component is used to allow users to follow us on social media, tracking can be added. When this is set to true, a JSON is added to a data-attribute called data-ga4-link, which is detected by ga4-link-tracker.js and pushed to the dataLayer.
65
+ data:
66
+ track_as_follow: true
67
+ links: [
68
+ {
69
+ href: 'follow',
70
+ text: 'Follow us on Facebook',
71
+ icon: 'facebook'
72
+ },
73
+ {
74
+ href: 'follow',
75
+ text: 'Follow us on Twitter',
76
+ icon: 'twitter'
77
+ },
57
78
  ]
58
79
  with_title:
59
80
  data:
@@ -20,12 +20,12 @@
20
20
  <% end %>
21
21
  </li>
22
22
  <li class="gem-c-feedback__option-list-item">
23
- <button class="govuk-button gem-c-feedback__prompt-link js-page-is-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffYesClick">
23
+ <button class="govuk-button gem-c-feedback__prompt-link js-page-is-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffYesClick" data-ga4='{"event_name":"form_submit","type":"feedback","text":"Yes", "section": "Is this page useful?"}'>
24
24
  <%= t("components.feedback.yes") %> <span class="govuk-visually-hidden"><%= t("components.feedback.is_useful") %></span>
25
25
  </button>
26
26
  </li>
27
27
  <li class="gem-c-feedback__option-list-item">
28
- <button class="govuk-button gem-c-feedback__prompt-link js-toggle-form js-page-is-not-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffNoClick" aria-controls="page-is-not-useful" aria-expanded="false">
28
+ <button class="govuk-button gem-c-feedback__prompt-link js-toggle-form js-page-is-not-useful" data-track-category="yesNoFeedbackForm" data-track-action="ffNoClick" aria-controls="page-is-not-useful" aria-expanded="false" data-ga4='{"event_name":"form_submit","type":"feedback","text":"No", "section": "Is this page useful?"}'>
29
29
  <%= t("components.feedback.no") %> <span class="govuk-visually-hidden"><%= t("components.feedback.is_not_useful") %></span>
30
30
  </button>
31
31
  </li>
@@ -232,12 +232,12 @@ en:
232
232
  navigation_search_heading: Search and popular pages
233
233
  navigation_search_subheading: Search
234
234
  popular_links:
235
- - label: 'Her Majesty Queen Elizabeth II'
236
- href: '/government/topical-events/her-majesty-queen-elizabeth-ii'
237
235
  - label: 'Check benefits and financial support you can get'
238
236
  href: '/check-benefits-financial-support'
239
237
  - label: 'Limits on energy prices: Energy Price Guarantee'
240
238
  href: '/government/publications/energy-bills-support/energy-bills-support-factsheet-8-september-2022'
239
+ - label: 'Find a job'
240
+ href: '/find-a-job'
241
241
  - label: 'Coronavirus (COVID-19)'
242
242
  href: '/coronavirus'
243
243
  - label: 'Universal Credit account: sign in'
@@ -295,11 +295,11 @@ en:
295
295
  title: Invasion of Ukraine
296
296
  links:
297
297
  - label: "UK visa support for Ukrainian nationals"
298
- href: "https://www.gov.uk/guidance/support-for-family-members-of-british-nationals-in-ukraine-and-ukrainian-nationals-in-ukraine-and-the-uk"
298
+ href: "https://www.gov.uk/guidance/support-for-family-members-of-british-nationals-in-ukraine-and-ukrainian-nationals-in-ukraine-and-the-uk"
299
299
  - label: "Move to the UK if you're coming from Ukraine"
300
300
  href: "https://www.gov.uk/guidance/move-to-the-uk-if-youre-from-ukraine"
301
301
  - label: "Homes for Ukraine: record your interest"
302
- href: "https://www.gov.uk/register-interest-homes-ukraine"
302
+ href: "https://www.gov.uk/register-interest-homes-ukraine"
303
303
  - label: "Find out about the UK’s response"
304
304
  href: "https://ukstandswithukraine.campaign.gov.uk/"
305
305
  world_locations: World locations
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "30.6.1".freeze
2
+ VERSION = "30.7.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 30.6.1
4
+ version: 30.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-16 00:00:00.000000000 Z
11
+ date: 2022-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -437,6 +437,7 @@ files:
437
437
  - app/assets/javascripts/govuk_publishing_components/all_components.js
438
438
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4.js
439
439
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js.erb
440
+ - app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-enhanced-ecommerce-tracker.js
440
441
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js
441
442
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js
442
443
  - app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js