Skip to content

Commit 88c32d1

Browse files
committed
Only show cookie banner if consent required
The cookie banner/option to set cookie preferences will only be used when attempting to track usage data via Google Tag Manager, at least initially. The gem already supports the alternative gtag.js approach and introducing a cookie banner consent step to that flow would be a breaking change
1 parent 2df037c commit 88c32d1

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

lib/source/layouts/core.erb

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,30 @@
5252
<script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');</script>
5353

5454
<div class="app-pane">
55-
<div class="govuk-cookie-banner" data-nosnippet role="region" aria-label="Cookies on <%= config[:tech_docs][:service_name] %>">
56-
<div class="govuk-cookie-banner__message govuk-width-container">
57-
<div class="govuk-grid-row">
58-
<div class="govuk-grid-column-two-thirds">
59-
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
60-
Cookies on <%= config[:tech_docs][:service_name] %>
61-
</h2>
62-
<div class="govuk-cookie-banner__content">
63-
<p class="govuk-body">We’d like to use analytics cookies so we can understand how you use the service and make improvements.</p>
55+
<% if config[:tech_docs][:ga4_gtm_tracking_id].is_a?(String) && !config[:tech_docs][:ga4_gtm_tracking_id].empty? %>
56+
<div class="govuk-cookie-banner" data-nosnippet role="region" aria-label="Cookies on <%= config[:tech_docs][:service_name] %>">
57+
<div class="govuk-cookie-banner__message govuk-width-container">
58+
<div class="govuk-grid-row">
59+
<div class="govuk-grid-column-two-thirds">
60+
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
61+
Cookies on <%= config[:tech_docs][:service_name] %>
62+
</h2>
63+
<div class="govuk-cookie-banner__content">
64+
<p class="govuk-body">We’d like to use analytics cookies so we can understand how you use the service and make improvements.</p>
65+
</div>
6466
</div>
6567
</div>
66-
</div>
67-
<div class="govuk-button-group">
68-
<button type="button" class="govuk-button" data-module="govuk-button">
69-
Accept analytics cookies
70-
</button>
71-
<button type="button" class="govuk-button" data-module="govuk-button">
72-
Reject analytics cookies
73-
</button>
68+
<div class="govuk-button-group">
69+
<button type="button" class="govuk-button" data-module="govuk-button">
70+
Accept analytics cookies
71+
</button>
72+
<button type="button" class="govuk-button" data-module="govuk-button">
73+
Reject analytics cookies
74+
</button>
75+
</div>
7476
</div>
7577
</div>
76-
</div>
78+
<% end %>
7779
<div class="app-pane__header toc-open-disabled">
7880
<a href="#content" class="govuk-skip-link" data-module="govuk-skip-link">Skip to main content</a>
7981

0 commit comments

Comments
 (0)