govuk_publishing_components 37.1.1 → 37.2.1
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/analytics-ga4/ga4-core.js +6 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js +2 -2
- data/app/assets/javascripts/govuk_publishing_components/lib/cookie-settings.js +109 -0
- data/app/assets/javascripts/govuk_publishing_components/load-analytics.js +83 -60
- data/app/models/govuk_publishing_components/audit_applications.rb +1 -1
- data/app/models/govuk_publishing_components/component_docs.rb +1 -1
- data/app/views/govuk_publishing_components/components/_details.html.erb +18 -2
- data/app/views/govuk_publishing_components/components/_image_card.html.erb +11 -11
- data/app/views/govuk_publishing_components/components/docs/details.yml +21 -0
- data/app/views/govuk_publishing_components/components/docs/image_card.yml +18 -11
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/axe.js +604 -440
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/package.json +1 -1
- data/node_modules/axe-core/sri-history.json +4 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd6a567dc9d2f526c099f1a5cffe3466e1198dd4e0dc0daa657fa1263ca747ee
|
4
|
+
data.tar.gz: 9b371409800e9c9bf9d78b8587a07c625824bdda222feea5a8eb19136adbece6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d542c5aa0c5a03260cd4df7c2752bef05c9e556ec5b7dad4a2fc2267f841d3d5c346b8b892606738ca6162833c0e8183b1c30521aceb3421dca539ab80dfe896
|
7
|
+
data.tar.gz: 938b1fca6df8b444cac7d2a0d5643c024d17b4c3bbe3488233457e970d5ab7c6a1bb5418bfa0790b45f04927695d48ba8b99344d4c29dd83eed843390fb8a302
|
@@ -34,8 +34,14 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
|
|
34
34
|
return navigator.userAgent
|
35
35
|
},
|
36
36
|
|
37
|
+
getTimestamp: function () {
|
38
|
+
return Date.now().toString()
|
39
|
+
},
|
40
|
+
|
37
41
|
sendData: function (data) {
|
38
42
|
data.govuk_gem_version = this.getGemVersion()
|
43
|
+
data.timestamp = this.getTimestamp()
|
44
|
+
|
39
45
|
// set this in the console as a debugging aid
|
40
46
|
if (window.GOVUK.analyticsGa4.showDebug) {
|
41
47
|
if (data.event_data) {
|
@@ -75,14 +75,14 @@
|
|
75
75
|
// given an object and a key, insert a value into object[key] if it exists
|
76
76
|
Schemas.prototype.addToObject = function (obj, key, value) {
|
77
77
|
if (key in obj) {
|
78
|
-
obj[key] = value
|
78
|
+
obj[key] = value + '' // ensure is a string
|
79
79
|
return obj
|
80
80
|
} else {
|
81
81
|
// check for one level of nesting in the object
|
82
82
|
for (var property in obj) {
|
83
83
|
if (this.isAnObject(obj[property])) {
|
84
84
|
if (key in obj[property]) {
|
85
|
-
obj[property][key] = value
|
85
|
+
obj[property][key] = value + '' // ensure is a string
|
86
86
|
return obj
|
87
87
|
}
|
88
88
|
}
|
@@ -0,0 +1,109 @@
|
|
1
|
+
window.GOVUK = window.GOVUK || {}
|
2
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
3
|
+
|
4
|
+
(function (Modules) {
|
5
|
+
function CookieSettings ($module) {
|
6
|
+
this.$module = $module
|
7
|
+
}
|
8
|
+
|
9
|
+
CookieSettings.prototype.init = function () {
|
10
|
+
this.$module.submitSettingsForm = this.submitSettingsForm.bind(this)
|
11
|
+
|
12
|
+
document.querySelector('form[data-module=cookie-settings]')
|
13
|
+
.addEventListener('submit', this.$module.submitSettingsForm)
|
14
|
+
|
15
|
+
this.setInitialFormValues()
|
16
|
+
}
|
17
|
+
|
18
|
+
CookieSettings.prototype.setInitialFormValues = function () {
|
19
|
+
if (!window.GOVUK.cookie('cookies_policy')) {
|
20
|
+
window.GOVUK.setDefaultConsentCookie()
|
21
|
+
}
|
22
|
+
|
23
|
+
var currentConsentCookie = window.GOVUK.cookie('cookies_policy')
|
24
|
+
var currentConsentCookieJSON = JSON.parse(currentConsentCookie)
|
25
|
+
|
26
|
+
// We don't need the essential value as this cannot be changed by the user
|
27
|
+
delete currentConsentCookieJSON.essential
|
28
|
+
|
29
|
+
for (var cookieType in currentConsentCookieJSON) {
|
30
|
+
var radioButton
|
31
|
+
|
32
|
+
if (currentConsentCookieJSON[cookieType]) {
|
33
|
+
radioButton = document.querySelector('input[name=cookies-' + cookieType + '][value=on]')
|
34
|
+
} else {
|
35
|
+
radioButton = document.querySelector('input[name=cookies-' + cookieType + '][value=off]')
|
36
|
+
}
|
37
|
+
|
38
|
+
if (radioButton) {
|
39
|
+
radioButton.checked = true
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
CookieSettings.prototype.submitSettingsForm = function (event) {
|
45
|
+
event.preventDefault()
|
46
|
+
|
47
|
+
var formInputs = event.target.getElementsByTagName('input')
|
48
|
+
var options = {}
|
49
|
+
|
50
|
+
for (var i = 0; i < formInputs.length; i++) {
|
51
|
+
var input = formInputs[i]
|
52
|
+
if (input.checked) {
|
53
|
+
var name = input.name.replace('cookies-', '')
|
54
|
+
var value = input.value === 'on'
|
55
|
+
|
56
|
+
options[name] = value
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
window.GOVUK.setConsentCookie(options)
|
61
|
+
window.GOVUK.setCookie('cookies_preferences_set', true, { days: 365 })
|
62
|
+
|
63
|
+
this.fireAnalyticsEvent(options)
|
64
|
+
|
65
|
+
this.showConfirmationMessage()
|
66
|
+
|
67
|
+
return false
|
68
|
+
}
|
69
|
+
|
70
|
+
CookieSettings.prototype.fireAnalyticsEvent = function (consent) {
|
71
|
+
var eventLabel = ''
|
72
|
+
|
73
|
+
for (var option in consent) {
|
74
|
+
var optionValue = consent[option] ? 'yes' : 'no'
|
75
|
+
eventLabel += option + '-' + optionValue + ' '
|
76
|
+
}
|
77
|
+
|
78
|
+
if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
|
79
|
+
window.GOVUK.analytics.trackEvent('cookieSettings', 'Save changes', { label: eventLabel })
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
CookieSettings.prototype.showConfirmationMessage = function () {
|
84
|
+
var confirmationMessage = document.querySelector('div[data-cookie-confirmation]')
|
85
|
+
// hide the message if already visible so assistive tech is triggered when it appears
|
86
|
+
confirmationMessage.style.display = 'none'
|
87
|
+
var previousPageLink = document.querySelector('.cookie-settings__prev-page')
|
88
|
+
var referrer = CookieSettings.prototype.getReferrerLink()
|
89
|
+
|
90
|
+
document.body.scrollTop = document.documentElement.scrollTop = 0
|
91
|
+
|
92
|
+
if (previousPageLink) {
|
93
|
+
if (referrer && referrer !== document.location.pathname) {
|
94
|
+
previousPageLink.href = referrer
|
95
|
+
previousPageLink.style.display = 'inline'
|
96
|
+
} else {
|
97
|
+
previousPageLink.style.display = 'none'
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
confirmationMessage.style.display = 'block'
|
102
|
+
}
|
103
|
+
|
104
|
+
CookieSettings.prototype.getReferrerLink = function () {
|
105
|
+
return document.referrer ? new URL(document.referrer).pathname : false
|
106
|
+
}
|
107
|
+
|
108
|
+
Modules.CookieSettings = CookieSettings
|
109
|
+
})(window.GOVUK.Modules)
|
@@ -3,49 +3,75 @@
|
|
3
3
|
//= require govuk_publishing_components/analytics/linked-domains
|
4
4
|
|
5
5
|
window.GOVUK.loadAnalytics = {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
6
|
+
domains: [
|
7
|
+
{
|
8
|
+
// need to have this one at the start, see loadGa4 function
|
9
|
+
name: 'development',
|
10
|
+
domains: [
|
11
|
+
'localhost',
|
12
|
+
'127.0.0.1',
|
13
|
+
'0.0.0.0',
|
14
|
+
'dev.gov.uk'
|
15
|
+
],
|
16
|
+
initialiseGA4: true,
|
17
|
+
id: 'GTM-MG7HG5W',
|
18
|
+
auth: 'bRiZ-jiEHtw6hHpGd6dF9w',
|
19
|
+
preview: 'env-3',
|
20
|
+
gaProperty: 'UA-UNSET',
|
21
|
+
gaPropertyCrossDomain: 'UA-UNSET'
|
22
|
+
},
|
23
|
+
{
|
24
|
+
name: 'production',
|
25
|
+
domains: [
|
26
|
+
'www.gov.uk',
|
27
|
+
'www-origin.publishing.service.gov.uk',
|
28
|
+
'assets.publishing.service.gov.uk'
|
29
|
+
],
|
30
|
+
initialiseGA4: true,
|
31
|
+
id: 'GTM-MG7HG5W',
|
32
|
+
gaProperty: 'UA-26179049-1',
|
33
|
+
gaPropertyCrossDomain: 'UA-145652997-1'
|
32
34
|
},
|
33
|
-
|
35
|
+
{
|
36
|
+
name: 'staging',
|
37
|
+
domains: [
|
38
|
+
'www.staging.publishing.service.gov.uk',
|
39
|
+
'www-origin.staging.publishing.service.gov.uk',
|
40
|
+
'assets.staging.publishing.service.gov.uk'
|
41
|
+
],
|
34
42
|
initialiseGA4: true,
|
43
|
+
id: 'GTM-MG7HG5W',
|
35
44
|
auth: 'oJWs562CxSIjZKn_GlB5Bw',
|
36
|
-
preview: 'env-5'
|
45
|
+
preview: 'env-5',
|
46
|
+
gaProperty: 'UA-26179049-20',
|
47
|
+
gaPropertyCrossDomain: 'UA-145652997-1'
|
37
48
|
},
|
38
|
-
|
49
|
+
{
|
50
|
+
name: 'integration',
|
51
|
+
domains: [
|
52
|
+
'www.integration.publishing.service.gov.uk',
|
53
|
+
'www-origin.integration.publishing.service.gov.uk',
|
54
|
+
'assets.integration.publishing.service.gov.uk'
|
55
|
+
],
|
39
56
|
initialiseGA4: true,
|
57
|
+
id: 'GTM-MG7HG5W',
|
40
58
|
auth: 'C7iYdcsOlYgGmiUJjZKrHQ',
|
41
|
-
preview: 'env-4'
|
59
|
+
preview: 'env-4',
|
60
|
+
gaProperty: 'UA-26179049-22',
|
61
|
+
gaPropertyCrossDomain: 'UA-145652997-1'
|
42
62
|
},
|
43
|
-
|
63
|
+
{
|
64
|
+
name: 'devdocs',
|
65
|
+
domains: [
|
66
|
+
'docs.publishing.service.gov.uk'
|
67
|
+
],
|
44
68
|
initialiseGA4: true,
|
45
|
-
|
46
|
-
preview: 'env-3'
|
69
|
+
id: 'GTM-TNKCK97'
|
47
70
|
}
|
48
|
-
|
71
|
+
],
|
72
|
+
|
73
|
+
// For Universal Analytics' cross domain tracking. linkedDomains is defined by the require statement at the top of the file.
|
74
|
+
linkedDomains: window.GOVUK.analytics.linkedDomains,
|
49
75
|
|
50
76
|
loadUa: function (currentDomain) {
|
51
77
|
currentDomain = currentDomain || window.location.hostname
|
@@ -57,17 +83,14 @@ window.GOVUK.loadAnalytics = {
|
|
57
83
|
window.GOVUK.analyticsVars.gaProperty = 'UA-UNSET'
|
58
84
|
window.GOVUK.analyticsVars.gaPropertyCrossDomain = 'UA-UNSET'
|
59
85
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
window.GOVUK.analyticsVars.gaProperty = 'UA-26179049-22'
|
68
|
-
window.GOVUK.analyticsVars.gaPropertyCrossDomain = 'UA-145652997-1'
|
86
|
+
for (var i = 0; i < this.domains.length; i++) {
|
87
|
+
var current = this.domains[i]
|
88
|
+
if (this.arrayContains(currentDomain, current.domains)) {
|
89
|
+
window.GOVUK.analyticsVars.gaProperty = current.gaProperty
|
90
|
+
window.GOVUK.analyticsVars.gaPropertyCrossDomain = current.gaPropertyCrossDomain
|
91
|
+
break
|
92
|
+
}
|
69
93
|
}
|
70
|
-
|
71
94
|
// Load universal analytics
|
72
95
|
if (typeof window.GOVUK.analyticsInit !== 'undefined') {
|
73
96
|
window.GOVUK.analyticsInit()
|
@@ -76,29 +99,29 @@ window.GOVUK.loadAnalytics = {
|
|
76
99
|
|
77
100
|
loadGa4: function (currentDomain) {
|
78
101
|
currentDomain = currentDomain || window.location.hostname
|
79
|
-
var environment =
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
102
|
+
var environment = false
|
103
|
+
// lots of dev domains, so simplify the matching process
|
104
|
+
if (currentDomain.match(/\/{2}[a-zA-Z0-9.]+dev\.gov\.uk/)) {
|
105
|
+
environment = this.domains[0]
|
106
|
+
} else {
|
107
|
+
for (var i = 0; i < this.domains.length; i++) {
|
108
|
+
if (this.arrayContains(currentDomain, this.domains[i].domains)) {
|
109
|
+
environment = this.domains[i]
|
110
|
+
break
|
111
|
+
}
|
112
|
+
}
|
90
113
|
}
|
91
114
|
|
92
115
|
// If we recognise the environment (i.e. the string isn't empty), load in GA4
|
93
116
|
if (environment) {
|
94
117
|
// If analytics-ga4.js exists and our detected environment has 'initialiseGA4' set to true, load GA4.
|
95
|
-
if (typeof window.GOVUK.analyticsGa4.init !== 'undefined' &&
|
118
|
+
if (typeof window.GOVUK.analyticsGa4.init !== 'undefined' && environment.initialiseGA4) {
|
96
119
|
window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {}
|
97
120
|
window.GOVUK.analyticsGa4.vars = window.GOVUK.analyticsGa4.vars || {}
|
98
|
-
window.GOVUK.analyticsGa4.vars.id =
|
99
|
-
window.GOVUK.analyticsGa4.vars.auth =
|
100
|
-
window.GOVUK.analyticsGa4.vars.preview =
|
101
|
-
window.GOVUK.analyticsGa4.vars.environment = environment // Used for testing and debugging
|
121
|
+
window.GOVUK.analyticsGa4.vars.id = environment.id
|
122
|
+
window.GOVUK.analyticsGa4.vars.auth = environment.auth
|
123
|
+
window.GOVUK.analyticsGa4.vars.preview = environment.preview
|
124
|
+
window.GOVUK.analyticsGa4.vars.environment = environment.name // Used for testing and debugging
|
102
125
|
|
103
126
|
window.GOVUK.analyticsGa4.vars.gem_version = 'not found'
|
104
127
|
var gemMeta = document.querySelector('meta[name="govuk:components_gem_version"]')
|
@@ -2,23 +2,39 @@
|
|
2
2
|
add_gem_component_stylesheet("details")
|
3
3
|
|
4
4
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
5
|
-
|
6
5
|
open ||= nil
|
6
|
+
disable_ga4 ||= false
|
7
|
+
@ga4 ||= OpenStruct.new(index_section: 0) unless disable_ga4
|
8
|
+
@ga4[:index_section] += 1 unless disable_ga4
|
9
|
+
ga4_attributes ||= {}
|
10
|
+
|
7
11
|
margin_bottom ||= 3
|
8
12
|
css_classes = %w(gem-c-details govuk-details)
|
9
13
|
css_classes << shared_helper.get_margin_bottom
|
10
14
|
|
11
15
|
details_data_attributes = {}
|
12
16
|
details_data_attributes[:module] = 'govuk-details gem-details'
|
17
|
+
details_data_attributes[:module] = 'govuk-details gem-details ga4-event-tracker' unless disable_ga4
|
13
18
|
|
14
19
|
data_attributes ||= {}
|
15
20
|
data_attributes[:details_track_click] = ''
|
21
|
+
unless disable_ga4
|
22
|
+
ga4_event = {
|
23
|
+
event_name: "select_content",
|
24
|
+
type: "detail",
|
25
|
+
text: title,
|
26
|
+
section: title,
|
27
|
+
index_section: @ga4[:index_section],
|
28
|
+
}
|
29
|
+
ga4_event.merge!(ga4_attributes)
|
30
|
+
data_attributes[:ga4_event] = ga4_event
|
31
|
+
end
|
16
32
|
|
17
33
|
summary_aria_attributes ||= {}
|
18
34
|
%>
|
19
35
|
<%= tag.details class: css_classes, data: details_data_attributes, open: open do %>
|
20
36
|
<%= tag.summary class: "govuk-details__summary", data: data_attributes, aria: summary_aria_attributes do %>
|
21
|
-
<span class="govuk-details__summary-text"
|
37
|
+
<span class="govuk-details__summary-text" <% unless disable_ga4 %>data-ga4-expandable<% end %>>
|
22
38
|
<%= title %>
|
23
39
|
</span>
|
24
40
|
<% end %>
|
@@ -7,13 +7,13 @@
|
|
7
7
|
brand_helper = GovukPublishingComponents::AppHelpers::BrandHelper.new(brand)
|
8
8
|
card_helper = GovukPublishingComponents::Presenters::ImageCardHelper.new(local_assigns, brand_helper)
|
9
9
|
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
|
11
|
+
component_helper.add_class("gem-c-image-card")
|
12
|
+
component_helper.add_class("govuk-grid-row") if card_helper.two_thirds
|
13
|
+
component_helper.add_class("gem-c-image-card--large") if card_helper.large
|
14
|
+
component_helper.add_class("gem-c-image-card--two-thirds") if card_helper.two_thirds
|
15
|
+
component_helper.add_class("gem-c-image-card--no-image") unless (card_helper.image_src || card_helper.youtube_video_id)
|
16
|
+
component_helper.add_class(brand_helper.brand_class) if brand_helper.brand_class
|
17
17
|
|
18
18
|
text_wrapper_classes = %w[gem-c-image-card__text-wrapper]
|
19
19
|
text_wrapper_classes << "gem-c-image-card__text-wrapper--two-thirds" if card_helper.two_thirds
|
@@ -34,12 +34,12 @@
|
|
34
34
|
]
|
35
35
|
extra_link_classes << brand_helper.color_class
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
component_helper.add_data_attribute({ module: "gem-track-click" }) if card_helper.is_tracking?
|
38
|
+
component_helper.add_data_attribute({ module: "image-card" }) if card_helper.youtube_video_id
|
39
|
+
component_helper.set_lang(card_helper.lang)
|
40
40
|
%>
|
41
41
|
<% if card_helper.href || card_helper.extra_details.any? %>
|
42
|
-
<%=
|
42
|
+
<%= tag.div(**component_helper.all_attributes) do %>
|
43
43
|
<%= content_tag(:div, class: text_wrapper_classes) do %>
|
44
44
|
<div class="gem-c-image-card__header-and-context-wrapper">
|
45
45
|
<% if card_helper.heading_text %>
|
@@ -61,6 +61,27 @@ examples:
|
|
61
61
|
tracking: GTM-123AB
|
62
62
|
block: |
|
63
63
|
We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.
|
64
|
+
with_ga4_tracking:
|
65
|
+
description: |
|
66
|
+
GA4 tracking is mostly handled internally by the component, apart from the required attribute `index_section_count`. This records the number of details components on the page and must be passed by the hosting application. Other GA4 attributes can also be passed if required, including to override attributes set by the component (for some reason this doesn't work in the component guide but works in applications).
|
67
|
+
|
68
|
+
The tracking automatically includes `index_section` as the index of the component on the page compared with other instances of the component that are also being tracked, e.g. the first details component on a page will be `index_section` 1, the second `index_section` 2, etc.
|
69
|
+
|
70
|
+
Link tracking for the contents of the details component is not included due to varying tracking requirements. If you need to track links in the component, wrap it in the application with the [GA4 link tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-link-tracker.md).
|
71
|
+
data:
|
72
|
+
title: What did the ground say to the train?
|
73
|
+
ga4_attributes: {
|
74
|
+
index_section_count: 6,
|
75
|
+
type: "not the default"
|
76
|
+
}
|
77
|
+
block: |
|
78
|
+
Between you and me, I've been tracked.
|
79
|
+
disable_ga4_tracking:
|
80
|
+
description: Disables GA4 tracking on the component. Tracking is enabled by default.
|
81
|
+
data:
|
82
|
+
title: No tracking here
|
83
|
+
disable_ga4: true
|
84
|
+
block: Or here, but thanks for looking.
|
64
85
|
open:
|
65
86
|
data:
|
66
87
|
title: Help with nationality
|
@@ -12,6 +12,7 @@ accessibility_criteria: |
|
|
12
12
|
- include alt text for images when present
|
13
13
|
- not have duplicate links for the image and the text
|
14
14
|
- if the contents of the component are in a different language than the rest of the document, include an appropriate `lang` attribute to correctly identify the language used in the component
|
15
|
+
uses_component_wrapper_helper: true
|
15
16
|
shared_accessibility_criteria:
|
16
17
|
- link
|
17
18
|
embed: |
|
@@ -276,6 +277,23 @@ examples:
|
|
276
277
|
}
|
277
278
|
}
|
278
279
|
]
|
280
|
+
with_ga4_tracking:
|
281
|
+
description: The component does not include an option for GA4 tracking, but data attributes to enable the [GA4 link tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-link-tracker.md) can be passed as shown.
|
282
|
+
data:
|
283
|
+
href: "/not-a-page"
|
284
|
+
image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
|
285
|
+
image_alt: "some meaningful alt text please"
|
286
|
+
heading_text: "News headline"
|
287
|
+
data_attributes:
|
288
|
+
module: "ga4-link-tracker"
|
289
|
+
ga4_link:
|
290
|
+
event_name: "navigation"
|
291
|
+
type: "homepage"
|
292
|
+
index_section: 1
|
293
|
+
index_link: 1
|
294
|
+
index_section_count: 1
|
295
|
+
index_total: 1
|
296
|
+
section: "homepage"
|
279
297
|
with_metadata:
|
280
298
|
description: Can be used for links to people pages to indicate payment type
|
281
299
|
data:
|
@@ -293,17 +311,6 @@ examples:
|
|
293
311
|
}
|
294
312
|
]
|
295
313
|
extra_details_no_indent: true
|
296
|
-
with_lang:
|
297
|
-
description: |
|
298
|
-
Pass through an appropriate `lang` to set a HTML lang attribute for the component.
|
299
|
-
|
300
|
-
The `lang` attribute **must** be set to a [valid BCP47 string](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang#Language_tag_syntax). A valid code can be the two or three letter language code - for example, English is `en` or `eng`, Korean is `ko` or `kor` - but if in doubt please check.
|
301
|
-
data:
|
302
|
-
href: "/not-a-page"
|
303
|
-
image_src: "https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/62756/s300_courts-of-justice.JPG"
|
304
|
-
image_alt: "some meaningful alt text please"
|
305
|
-
heading_text: Yr hyn rydym ni'n ei wneud
|
306
|
-
lang: cy
|
307
314
|
with_sizes_attribute:
|
308
315
|
description: |
|
309
316
|
`sizes` is an attribute that makes use of html's native responsive images functionality.
|