Skip to content

Commit 836a754

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 The conditional used here is similar to one used by the gtag.js partial
1 parent 07f4034 commit 836a754

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
<div class="govuk-cookie-banner" data-nosnippet role="region" aria-label="Cookies on <%= config[:tech_docs][:service_name] %>">
2-
<div class="govuk-cookie-banner__message govuk-width-container">
3-
<div class="govuk-grid-row">
4-
<div class="govuk-grid-column-two-thirds">
5-
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
6-
Cookies on <%= config[:tech_docs][:service_name] %>
7-
</h2>
8-
<div class="govuk-cookie-banner__content">
9-
<p class="govuk-body">We’d like to use analytics cookies so we can understand how you use the service and make improvements.</p>
1+
<% if config[:tech_docs][:ga4_gtm_tracking_id].is_a?(String) && !config[:tech_docs][:ga4_gtm_tracking_id].empty? %>
2+
<div class="govuk-cookie-banner" data-nosnippet role="region" aria-label="Cookies on <%= config[:tech_docs][:service_name] %>">
3+
<div class="govuk-cookie-banner__message govuk-width-container">
4+
<div class="govuk-grid-row">
5+
<div class="govuk-grid-column-two-thirds">
6+
<h2 class="govuk-cookie-banner__heading govuk-heading-m">
7+
Cookies on <%= config[:tech_docs][:service_name] %>
8+
</h2>
9+
<div class="govuk-cookie-banner__content">
10+
<p class="govuk-body">We’d like to use analytics cookies so we can understand how you use the service and make improvements.</p>
11+
</div>
1012
</div>
1113
</div>
12-
</div>
13-
<div class="govuk-button-group">
14-
<button type="button" class="govuk-button" data-module="govuk-button">
15-
Accept analytics cookies
16-
</button>
17-
<button type="button" class="govuk-button" data-module="govuk-button">
18-
Reject analytics cookies
19-
</button>
14+
<div class="govuk-button-group">
15+
<button type="button" class="govuk-button" data-module="govuk-button">
16+
Accept analytics cookies
17+
</button>
18+
<button type="button" class="govuk-button" data-module="govuk-button">
19+
Reject analytics cookies
20+
</button>
21+
</div>
2022
</div>
2123
</div>
22-
</div>
24+
<% end %>

0 commit comments

Comments
 (0)