senternet-site-gdpr

Implements a geo-scoped cookie consent banner that gates Google Analytics for EEA and UK visitors.

Updated May 8, 2026
One-click install
npx skills add https://github.com/MattSenter/senternet-site-skills --skill senternet-site-gdpr-mattsenter
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: senternet-site-gdpr
Source: https://github.com/MattSenter/senternet-site-skills/tree/main/.claude/skills/senternet-site-gdpr
Command: npx skills add https://github.com/MattSenter/senternet-site-skills --skill senternet-site-gdpr-mattsenter

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Sites serving EEA and UK visitors must obtain prior consent before loading analytics cookies, but most consent banners either nag worldwide traffic or fail to actually block Google Analytics. This Skill adds a footer toaster that only appears for visitors in consent-required regions and prevents gtag from loading until the visitor accepts. ## Core Features & Use Cases - Geo-scoped consent detection: Resolves the visitor's country via a same-origin /api/geo route reading CDN headers or a server-side IP lookup, showing the banner only for EU 27, EEA, and GB visitors. - Consent-gated analytics: Stores the choice in localStorage and imperatively injects the gtag script only after acceptance, with reject and unknown-region paths keeping analytics off. - Framework tracks: Provides wiring for both Next.js App Router (route handlers, client components) and Vite (Hosting rewrite or Cloud Function for geo, stripped index.html GA block). - Use Case: After wiring Google Analytics on a marketing site, run this Skill to add the consent banner, update the Privacy Policy, and verify that EU-forced sessions load gtag only after clicking Allow all. ## Quick Start Add a GDPR cookie consent banner to my site that only shows for EU and UK visitors and blocks Google Analytics until they accept.

Frequently Asked Questions about senternet-site-gdpr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a GDPR cookie consent banner to a Next.js site?▼

Add a same-origin /api/geo route that resolves the visitor's country from CDN headers or a server-side IP lookup, then mount a footer toaster client component that renders only when the region requires consent. Store the choice in localStorage and inject the gtag script imperatively after acceptance.

How do I block Google Analytics until cookie consent is given?▼

Do not include the gtag script in initial HTML; instead create it with document.createElement only after the visitor clicks Allow all or when geo resolves to a non-consent region. The next/script afterInteractive strategy often never inserts tags after first paint, so imperative injection is required.

Does this consent approach work with Vite and Firebase Hosting?▼

Yes, the Vite track uses a Firebase Hosting rewrite to a small Cloud Function for geo resolution instead of a Next.js route handler. You must also strip or consent-gate the unconditional GA block in index.html so prerendered pages never include a live gtag tag.

Should Firebase anonymous auth be gated behind cookie consent?▼

No, anonymous Firebase authentication and reCAPTCHA are strictly necessary storage and must stay on regardless of the consent choice. Only analytics cookies like Google Analytics are gated; disclose the essential storage in the Privacy Policy instead.

Why does the consent banner not appear for US visitors?▼

The banner is geo-scoped by design: it renders only when the resolved country is in the EU 27, EEA, or GB. Visitors from other regions, private IPs, or unresolved regions see no banner, and analytics loads without a prompt when the region is confirmed not required.