From 3a8f69c2f4ef15f82f0cf946cb1d0af8adb6e892 Mon Sep 17 00:00:00 2001 From: Matt Spencer Date: Wed, 12 Jan 2022 15:17:53 +0000 Subject: [PATCH] Add cookie consent and Google Analytics Add Cookie consent 'toast' Only load google analytics if consent is given Add a cookie and privacy policy page Signed-off-by: Matt Spencer --- config.toml | 25 +++++++++ content/legal/privacy_policy.md | 35 +++++++++++++ themes/soafee/assets/js/cookie_consent.js | 52 +++++++++++++++++++ themes/soafee/layouts/_default/baseof.html | 5 ++ .../layouts/partials/cookie_consent.html | 19 +++++++ .../layouts/partials/google_analytics.html | 49 +++++++++++++++++ .../partials/google_analytics_body.html | 8 +++ themes/soafee/layouts/partials/head.html | 9 +++- 8 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 content/legal/privacy_policy.md create mode 100644 themes/soafee/assets/js/cookie_consent.js create mode 100644 themes/soafee/layouts/partials/cookie_consent.html create mode 100644 themes/soafee/layouts/partials/google_analytics.html create mode 100644 themes/soafee/layouts/partials/google_analytics_body.html diff --git a/config.toml b/config.toml index 4cd4bc4..f084dea 100644 --- a/config.toml +++ b/config.toml @@ -2,11 +2,36 @@ baseURL = "https://soafee.io" languageCode = "en-us" title = "SOAFEE" theme = "soafee" +googleAnalytics = "GTM-WLHTXFF" [Author] name = "J. Sickmeyer" +[privacy] + [privacy.disqus] + disable = true + [privacy.googleAnalytics] + anonymizeIP = false + disable = false + respectDoNotTrack = false + useSessionStorage = false + [privacy.instagram] + disable = true + simple = false + [privacy.twitter] + disable = true + enableDNT = false + simple = false + [privacy.vimeo] + disable = true + enableDNT = false + simple = false + [privacy.youtube] + disable = true + privacyEnhanced = false + + #[[menu.main]] # name = "Home" # pre = "home" diff --git a/content/legal/privacy_policy.md b/content/legal/privacy_policy.md new file mode 100644 index 0000000..b4e4339 --- /dev/null +++ b/content/legal/privacy_policy.md @@ -0,0 +1,35 @@ +--- +Title: Cookie and Privacy Policy +--- + +# Cookie and Privacy Policy + +We take your privacy very seriously and are committed to safeguarding your personal data. This Privacy Policy ("Policy") informs you how the SOAFEE SIG collect, process, transfer and protect personal data. + +In this Policy, "personal data" means any information which on its own or combined with other information relates to and identifies (directly or indirectly) a living individual. + +## Scope + +This policy applies to all SOAFEE.io websites, domains, services, applications and products. + +It does not apply to third-party applications, websites, products, services or social media platforms that may be accessed through links that we provide to you. These sites are owned and operated independently from us and have their own separate privacy and data collection practices. Any personal data that you provide to these websites will be governed by the terms of the third party's own privacy policy. We cannot accept liability for the actions or policies of these independent sites and are not responsible for the content or privacy practices of such sites. + +## Types of Data We Collect and How + +### Data you provide + +Out website does ask for or store any personal data. + +### Data we automatically collect + +When you visit our website we automatically collect and store information about your visit using browser cookies (files which are sent by us to your computer) or similar technology. + +Cookies we use are: + +|Company/Provider | Purpose | +|-----------------|---------| +| Google | Analytics tracking (via Google Tag Manager) | + +## How we use Personal Data we collect + +Our website does not collect any personal data. \ No newline at end of file diff --git a/themes/soafee/assets/js/cookie_consent.js b/themes/soafee/assets/js/cookie_consent.js new file mode 100644 index 0000000..7861a56 --- /dev/null +++ b/themes/soafee/assets/js/cookie_consent.js @@ -0,0 +1,52 @@ +function setCookie(name,value,days) { + var expires = ""; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days*24*60*60*1000)); + expires = "; expires=" + date.toUTCString(); + } + document.cookie = name + "=" + (value || "") + expires + "; path=/"; +} +function getCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; +} + +function eraseCookie(name) { + document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; +} + +function cookieConsent() { + console.log("Checking for cookie consent"); + if (!getCookie('cookieConsent')) { + var element=document.getElementById('cookieConsent'); + var toast = new bootstrap.Toast(element); + toast.show(); + } +} + +function updateConsent() { + let event = new Event("soafee_consent_update", {"bubbles": false}); + document.dispatchEvent(event); +} + +$('#btnDeny').click(()=>{ + setCookie('cookieConsent','no',365); + $('.toast').toast('hide'); + updateConsent(); +}) + +$('#btnAccept').click(()=>{ + setCookie('cookieConsent','yes',365); + $('.toast').toast('hide'); + updateConsent(); +}) + +// load +cookieConsent(); \ No newline at end of file diff --git a/themes/soafee/layouts/_default/baseof.html b/themes/soafee/layouts/_default/baseof.html index 8a3cb93..3edd89b 100644 --- a/themes/soafee/layouts/_default/baseof.html +++ b/themes/soafee/layouts/_default/baseof.html @@ -3,6 +3,9 @@ {{- partial "head.html" . -}} + {{ partial "google_analytics_body.html" . }} + +
{{- partial "header.html" . -}}
@@ -19,6 +22,8 @@ + + {{ partial "cookie_consent.html" . }} \ No newline at end of file diff --git a/themes/soafee/layouts/partials/cookie_consent.html b/themes/soafee/layouts/partials/cookie_consent.html new file mode 100644 index 0000000..493a2c2 --- /dev/null +++ b/themes/soafee/layouts/partials/cookie_consent.html @@ -0,0 +1,19 @@ +
+ +
\ No newline at end of file diff --git a/themes/soafee/layouts/partials/google_analytics.html b/themes/soafee/layouts/partials/google_analytics.html new file mode 100644 index 0000000..edac94e --- /dev/null +++ b/themes/soafee/layouts/partials/google_analytics.html @@ -0,0 +1,49 @@ +{{- $pc := .Site.Config.Privacy.GoogleAnalytics -}} +{{- if not $pc.Disable }}{{ with .Site.GoogleAnalytics -}} + +{{- end }}{{ end -}} diff --git a/themes/soafee/layouts/partials/google_analytics_body.html b/themes/soafee/layouts/partials/google_analytics_body.html new file mode 100644 index 0000000..960db0b --- /dev/null +++ b/themes/soafee/layouts/partials/google_analytics_body.html @@ -0,0 +1,8 @@ +{{- $pc := .Site.Config.Privacy.GoogleAnalytics -}} +{{- if not $pc.Disable }}{{ with .Site.GoogleAnalytics -}} +{{ if hasPrefix . "GTM-"}} + +{{end}} +{{end}}{{end}} \ No newline at end of file diff --git a/themes/soafee/layouts/partials/head.html b/themes/soafee/layouts/partials/head.html index 06d443d..7df219c 100644 --- a/themes/soafee/layouts/partials/head.html +++ b/themes/soafee/layouts/partials/head.html @@ -19,5 +19,12 @@ {{ $style := resources.Get "sass/main.scss" | toCSS $options | minify }} - + + {{ $js := resources.Get "js/cookie_consent.js" | js.Build "main.js" }} + + + + + + {{- partial "google_analytics" . }} \ No newline at end of file -- GitLab