Add a cookie banner that gates Google Analytics behind consent. The measurement ID is [G-XXXXXXXXXX]. Style it from the tokens and put it in the footer template.
Before you start: if the ID above is still the placeholder, ask me for it and wait. If Site Kit is installed, tell me to turn off “Let Site Kit place the Google tag” first. Remind me to turn on redaction for email addresses and URL query parameters in the GA4 data stream.
1. Run get-design-context and find the default footer template, so the card is on every page.
2. Add a card at the bottom right: a title, one sentence, a link to the privacy policy, Decline as an outline button and Accept as the primary button. On a phone the card is full width and Accept is on top. Use the button component and the colour, type and spacing tokens. The card ships with the hidden attribute and only the script shows it. It is a labelled region, not a modal.
3. Put the measurement ID on the card (data-ga-id). Load gtag.js only after Accept and only for a real G- ID, with Consent Mode v2 in its basic form: analytics granted, all ad signals denied. The value “preview” shows the card with no analytics.
4. Keep the choice in one first-party cookie for 180 days, versioned with data-consent-version. Add a Cookie settings control next to the footer legal links that opens the card again. Decline after Accept removes the Google cookies. Logged-in users are not measured. A browser that sends Global Privacy Control counts as Decline.
5. Test three states in a browser: first visit (the card shows, no cookies), Accept (the _ga cookies appear), and Decline from Cookie settings (the cookies are gone).
6. Add a Cookies and analytics section to the privacy policy: the banner and the Cookie settings link, the consent cookie and its 180 days, what Analytics records, the two Google cookies and their two-year life, consent as the legal basis, and Google LLC under the EU-US Data Privacy Framework. Then write the rule into the site notes, so a later change cannot put the tag in front of the banner.
Show me each change as a diff and wait for my approval before you write.
A cookie banner that gates Google Analytics
A 2 KB consent banner that keeps Google Analytics out of the browser until the visitor accepts. No plugin.