govuk_publishing_components 37.8.1 → 37.9.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/analytics-ga4/ga4-focus-loss-tracker.js +61 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +1 -0
- data/app/views/govuk_publishing_components/components/_option_select.html.erb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 620e260c7be413ed137d8e74b40dc48c19319aec32a0a7d19cc595ac63f88ace
|
4
|
+
data.tar.gz: aa8cc4913d9db8852e43c7eb3e47f43716b749c640ba31b4004ad60f78c88ea2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de3cdf70234ce290d51b5132f6cde36fc6c43f5c2281fc5f094a468ee5b496bbc49325e4633ff01836bcafa4c6e4ac30af496e40034c50dd2e6da27b847ed2f1
|
7
|
+
data.tar.gz: 56b4d106d440fbc30dd4ad64108cc9f3dbdba4c65a23a37df3147e80e8703ccc3e91349cfe65d7ee484068abe0ee07366ea8a1abc742798f19c68d5877c02513
|
data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-focus-loss-tracker.js
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
window.GOVUK = window.GOVUK || {}
|
2
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
3
|
+
|
4
|
+
(function (Modules) {
|
5
|
+
'use strict'
|
6
|
+
|
7
|
+
function Ga4FocusLossTracker (module) {
|
8
|
+
this.module = module
|
9
|
+
this.trackingTrigger = 'data-ga4-focus-loss' // elements with this attribute get tracked
|
10
|
+
}
|
11
|
+
|
12
|
+
Ga4FocusLossTracker.prototype.init = function () {
|
13
|
+
var consentCookie = window.GOVUK.getConsentCookie()
|
14
|
+
|
15
|
+
if (consentCookie && consentCookie.usage) {
|
16
|
+
this.startModule()
|
17
|
+
} else {
|
18
|
+
this.start = this.startModule.bind(this)
|
19
|
+
window.addEventListener('cookie-consent', this.start)
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
// triggered by cookie-consent event, which happens when users consent to cookies
|
24
|
+
Ga4FocusLossTracker.prototype.startModule = function () {
|
25
|
+
if (window.dataLayer) {
|
26
|
+
window.removeEventListener('cookie-consent', this.start)
|
27
|
+
this.module.addEventListener('blur', this.trackFocusLoss.bind(this))
|
28
|
+
this.module.piiRemover = new window.GOVUK.analyticsGa4.PIIRemover()
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
Ga4FocusLossTracker.prototype.trackFocusLoss = function (event) {
|
33
|
+
var data = event.target.getAttribute(this.trackingTrigger)
|
34
|
+
if (!data) {
|
35
|
+
return
|
36
|
+
}
|
37
|
+
|
38
|
+
try {
|
39
|
+
data = JSON.parse(data)
|
40
|
+
} catch (e) {
|
41
|
+
// if there's a problem with the config, don't start the tracker
|
42
|
+
console.warn('GA4 configuration error: ' + e.message, window.location)
|
43
|
+
return
|
44
|
+
}
|
45
|
+
|
46
|
+
var tagName = event.target.tagName
|
47
|
+
var inputType = event.target.getAttribute('type')
|
48
|
+
|
49
|
+
if (data.text) {
|
50
|
+
data.text = this.module.piiRemover.stripPIIWithOverride(data.text, true, true)
|
51
|
+
} else {
|
52
|
+
if (tagName === 'INPUT' && (inputType === 'search' || inputType === 'text')) {
|
53
|
+
data.text = window.GOVUK.analyticsGa4.core.trackFunctions.standardiseSearchTerm(this.module.value)
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
window.GOVUK.analyticsGa4.core.applySchemaAndSendData(data, 'event_data')
|
58
|
+
}
|
59
|
+
|
60
|
+
Modules.Ga4FocusLossTracker = Ga4FocusLossTracker
|
61
|
+
})(window.GOVUK.Modules)
|
@@ -50,7 +50,7 @@
|
|
50
50
|
<svg version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="0" height="0" class="gem-c-option-select__icon gem-c-option-select__icon--down" aria-hidden="true" focusable="false"><path d="m225.84 414.16l256 256c16.683 16.683 43.691 16.683 60.331 0l256-256c16.683-16.683 16.683-43.691 0-60.331s-43.691-16.683-60.331 0l-225.84 225.84-225.84-225.84c-16.683-16.683-43.691-16.683-60.331 0s-16.683 43.691 0 60.331z"/></svg>
|
51
51
|
</h3>
|
52
52
|
|
53
|
-
<%= content_tag(:div,
|
53
|
+
<%= content_tag(:div, class: options_container_classes, id: options_container_id, tabindex: "-1") do %>
|
54
54
|
<div class="gem-c-option-select__container-inner js-auto-height-inner">
|
55
55
|
<% if show_filter %>
|
56
56
|
<span id="<%= checkboxes_count_id %>"
|
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: 37.
|
4
|
+
version: 37.9.0
|
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: 2024-03-
|
11
|
+
date: 2024-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|
@@ -456,6 +456,7 @@ files:
|
|
456
456
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js
|
457
457
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js
|
458
458
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js
|
459
|
+
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-focus-loss-tracker.js
|
459
460
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-tracker.js
|
460
461
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js
|
461
462
|
- app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js
|