Skip to content

Commit

Permalink
Cookie consent adjustments to test on staging
Browse files Browse the repository at this point in the history
  • Loading branch information
oisa committed Nov 28, 2024
1 parent dfb9fbb commit e5a0ee5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 29 deletions.
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,14 @@ function renamePathForProd() {

function addAnalytics() {
return src(`${config.dir.build}/**/*.html`)
.pipe(inject.after('<head>', `<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
.pipe(inject.after('<head>', `<script data-category="analytics">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-P2NKBBJZ');</script>
`))
.pipe(inject.after('<head>', `<script async src="https://www.googletagmanager.com/gtag/js?id=G-49T9M12F86"></script>
<script>
.pipe(inject.after('<head>', `<script async data-category="analytics" src="https://www.googletagmanager.com/gtag/js?id=G-49T9M12F86"></script>
<script data-category="analytics">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
Expand Down
14 changes: 7 additions & 7 deletions src/components/cookie-consent/_cookie-consent.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@
<hr />
<ul class="nsw-cookie-dialog__list">
<li class="nsw-cookie-dialog__list-item">
<input class="nsw-form__checkbox-input" value="foo" type="checkbox" name="form-checkbox-multi-2" id="cookie-settings-1">
<label class="nsw-form__checkbox-label" for="cookie-settings-1">Foo</label>
<input class="nsw-form__checkbox-input" value="analytics" type="checkbox" name="form-checkbox-multi-1" id="cookie-settings-1">
<label class="nsw-form__checkbox-label" for="cookie-settings-1">Marketing cookies (optional)</label>
<div class="nsw-cookie-dialog__cookie-details">
<p>These cookies help us understand how you interact with the site. We use this data to identify areas to improve.</p>
<p>These cookies are used to optimise marketing communications and show you ads on other sites.</p>
</div>
</li>
<li class="nsw-cookie-dialog__list-item">
<input class="nsw-form__checkbox-input" value="analytics" type="checkbox" name="form-checkbox-multi-2" id="cookie-settings-2">
<label class="nsw-form__checkbox-label" for="cookie-settings-2">Marketing cookies (optional)</label>
<input class="nsw-form__checkbox-input" value="foo" type="checkbox" name="form-checkbox-multi-2" id="cookie-settings-2">
<label class="nsw-form__checkbox-label" for="cookie-settings-2">Foo</label>
<div class="nsw-cookie-dialog__cookie-details">
<p>These cookies are used to optimise marketing communications and show you ads on other sites.</p>
<p>These cookies help us understand how you interact with the site. We use this data to identify areas to improve.</p>
</div>
</ul>
</li>
</ul>
</section>
<section id="cookie-information" class="nsw-tabs__content nsw-tabs__content--side-flush">
Expand Down
5 changes: 4 additions & 1 deletion src/components/cookie-consent/cookie-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class CookieConsent {
throw new Error('Use CookieConsent.getInstance() to get the Singleton instance')
}

this.config = config
this.config = {
...this.config,
enabled: false,
}
this.bannerElement = element
this.isInitialized = false

Expand Down
31 changes: 13 additions & 18 deletions src/global/handlebars/layouts/layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/languages/xml.min.js"></script>
{{/unless}}
<!-- Hotjar Tracking Code for NSW Design System -->
<script>
(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:5063548,hjsv:6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
<script data-category="analytics">
(function (h, o, t, j, a, r) {
h.hj = h.hj || function () { (h.hj.q = h.hj.q || []).push(arguments) };
h._hjSettings = { hjid: 5063548, hjsv: 6 };
a = o.getElementsByTagName('head')[0];
r = o.createElement('script'); r.async = 1;
r.setAttribute('data-category', 'analytics');
r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
a.appendChild(r);
})(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
</script>
<script
type="text/plain"
Expand All @@ -55,7 +56,6 @@
analytics: {},
foo: {},
},
onFirstConsent: (preferences) => console.log('Accepted:', preferences),
onConsent: (preferences) => console.log('Accepted:', preferences),
language: {
default: 'en',
Expand All @@ -76,19 +76,15 @@
closeIconLabel: 'Close modal',
sections: [
{
title: 'Somebody said ... cookies?',
description: 'I want one!',
title: 'Foo',
description: 'These cookies collect information about how you use our website. All of the data is anonymized and cannot be used to identify you.',
linkedCategory: 'foo',
},
{
title: 'Performance and Analytics',
description: 'These cookies collect information about how you use our website. All of the data is anonymized and cannot be used to identify you.',
linkedCategory: 'analytics',
},
{
title: 'Foo',
description: 'These cookies collect information about how you use our website. All of the data is anonymized and cannot be used to identify you.',
linkedCategory: 'foo',
},
],
},
},
Expand All @@ -99,7 +95,6 @@
const cookieConsent = document.querySelector('.js-cookie-consent')
new window.NSW.CookieConsent(config, cookieConsent)
})
</script>
</head>

Expand Down

0 comments on commit e5a0ee5

Please sign in to comment.