Add GA tracking back and privacy policy page

This commit is contained in:
engboris 2025-12-08 22:47:35 +01:00
parent 9e74614aef
commit 387c201590
4 changed files with 202 additions and 0 deletions

View File

@ -0,0 +1,101 @@
---
/**
* Cookie consent banner component.
* Displays a GDPR-compliant cookie consent banner at the bottom of the page.
* Manages user consent for analytics cookies via localStorage.
*/
---
<div
id="cookie-banner"
class="fixed bottom-0 left-0 right-0 z-50 hidden"
role="dialog"
aria-labelledby="cookie-banner-title"
aria-describedby="cookie-banner-description"
>
<div class="bg-base-200 border-t border-base-300 p-4 shadow-lg">
<div class="container mx-auto max-w-4xl">
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
<div class="flex-1">
<h2 id="cookie-banner-title" class="font-semibold mb-1">Cookie Consent</h2>
<p id="cookie-banner-description" class="text-sm text-base-content/80">
We use cookies to analyze site traffic with Google Analytics.
<a href="/privacy/" class="link link-primary">Learn more</a>
</p>
</div>
<div class="flex gap-2 flex-shrink-0">
<button
id="cookie-decline"
class="btn btn-sm btn-ghost"
type="button"
>
Decline
</button>
<button
id="cookie-accept"
class="btn btn-sm btn-primary"
type="button"
>
Accept
</button>
</div>
</div>
</div>
</div>
</div>
<script is:inline>
(function() {
const CONSENT_KEY = 'cookie-consent';
const banner = document.getElementById('cookie-banner');
const acceptBtn = document.getElementById('cookie-accept');
const declineBtn = document.getElementById('cookie-decline');
/**
* Loads Google Analytics scripts dynamically.
*/
function loadGoogleAnalytics() {
if (document.getElementById('ga-script')) return;
const script = document.createElement('script');
script.id = 'ga-script';
script.async = true;
script.src = 'https://www.googletagmanager.com/gtag/js?id=G-7308Y1HGM9';
document.head.appendChild(script);
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-7308Y1HGM9');
}
/**
* Saves consent preference and handles banner visibility.
* @param {boolean} consented - Whether the user consented to cookies.
*/
function setConsent(consented) {
localStorage.setItem(CONSENT_KEY, consented ? 'granted' : 'denied');
banner.classList.add('hidden');
if (consented) {
loadGoogleAnalytics();
}
}
/**
* Checks stored consent and shows banner if no decision has been made.
*/
function checkConsent() {
const consent = localStorage.getItem(CONSENT_KEY);
if (consent === 'granted') {
loadGoogleAnalytics();
} else if (consent === null) {
banner.classList.remove('hidden');
}
}
acceptBtn.addEventListener('click', function() { setConsent(true); });
declineBtn.addEventListener('click', function() { setConsent(false); });
checkConsent();
})();
</script>

View File

@ -5,6 +5,7 @@
<a href="/members/" class="link link-hover">Members</a>
<a href="/meetings/" class="link link-hover">Meetings</a>
<a href="/resources/" class="link link-hover">Resources</a>
<a href="/privacy/" class="link link-hover">Privacy</a>
</nav>
<nav>
<div class="grid grid-flow-col gap-4">

View File

@ -2,6 +2,7 @@
import "../styles/global.css";
import Navbar from "../components/Navbar.astro";
import Footer from "../components/Footer.astro";
import CookieBanner from "../components/CookieBanner.astro";
import logo from "../assets/logo.svg";
import { SEO } from "astro-seo";
@ -81,5 +82,6 @@ const seoConfig = {
</main>
<Footer />
<CookieBanner />
</body>
</html>

98
src/pages/privacy.astro Normal file
View File

@ -0,0 +1,98 @@
---
import Layout from '../layouts/Layout.astro';
---
<Layout seo={{ title: "Privacy Policy", description: "Privacy policy for the ReFL website" }}>
<div class="max-w-3xl mx-auto prose prose-invert">
<h1>Privacy Policy</h1>
<p class="text-base-content/70">Last updated: December 2025</p>
<h2>Introduction</h2>
<p>
ReFL (Réflexions sur les Fondements de la Logique) is committed to protecting your privacy.
This policy explains how we collect, use, and safeguard information when you visit our website.
</p>
<h2>Information We Collect</h2>
<h3>Analytics Data</h3>
<p>
With your consent, we use Google Analytics to collect anonymous usage data to help us understand
how visitors interact with our website. This includes:
</p>
<ul>
<li>Pages visited and time spent on pages</li>
<li>Referring websites</li>
<li>Browser type and device information</li>
<li>Approximate geographic location (country/city level)</li>
</ul>
<p>
This data is aggregated and does not personally identify you. Google Analytics uses cookies
to collect this information. You can opt out of analytics tracking by declining cookies when
prompted.
</p>
<h3>Local Storage</h3>
<p>
We use your browser's local storage to remember:
</p>
<ul>
<li>Your cookie consent preference</li>
<li>Your theme preference (light/dark mode)</li>
</ul>
<p>
This data is stored only in your browser and is not transmitted to our servers.
</p>
<h2>How We Use Information</h2>
<p>
We use the collected analytics data solely to:
</p>
<ul>
<li>Understand which content is most useful to our visitors</li>
<li>Improve the website's structure and content</li>
<li>Ensure the website works correctly across different browsers and devices</li>
</ul>
<h2>Third-Party Services</h2>
<p>
We use the following third-party services:
</p>
<ul>
<li>
<strong>Google Analytics</strong> - For website analytics.
<a href="https://policies.google.com/privacy" target="_blank" rel="noopener noreferrer" class="link link-primary">
Google's Privacy Policy
</a>
</li>
<li>
<strong>Google Fonts</strong> - For typography. Font files are loaded from Google's servers.
</li>
</ul>
<h2>Your Rights</h2>
<p>You have the right to:</p>
<ul>
<li>Decline analytics cookies when visiting our website</li>
<li>Clear your browser's cookies and local storage at any time</li>
<li>Use browser extensions to block tracking scripts</li>
</ul>
<h2>Managing Your Consent</h2>
<p>
You can change your cookie preferences at any time by clearing your browser's local storage
for this website. The consent banner will appear again on your next visit.
</p>
<h2>Contact</h2>
<p>
If you have questions about this privacy policy, please contact us at
<a href="mailto:refl@framalistes.org" class="link link-primary">refl@framalistes.org</a>.
</p>
<h2>Changes to This Policy</h2>
<p>
We may update this privacy policy from time to time. Any changes will be posted on this page
with an updated revision date.
</p>
</div>
</Layout>