Repository navigation
Google Tag Manager behind a cookie banner, in place of GA4 without one - #154
Merged
Merged
Conversation
… without one GTM_ID, a repository variable given to production's build alone, replaces GA_ID. public/consent.js loads nothing of Google's until a reader accepts the banner (Footer.astro, moved to the body so the sidebar can't cover it); Cookies in the footer asks again, and a No after a Yes takes consent back and deletes Google's cookies. With no GTM_ID: no script, no banner, no Google address in the policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The site should measure which pages get read through Google Tag Manager, with a cookie banner a reader answers, the same way the blog does.
What changes
GTM_IDreplacesGA_IDinpages.yml, theDockerfile,Taskfile.ymlandastro.config.mjs: a repository variable, given to production's build alone.GA_IDwas never set, so nothing measured before this either.public/consent.jsreplacespublic/ga.js. Consent Mode v2 starts denied and nothing of Google's loads until Accept; thenanalytics_storageis granted andgtm.jsloads. Ads consent stays denied.Footer.astro): one sentence, "No, thanks" and "Accept" with the same weight, fixed over the foot of the page. The script moves it to<body>: inside the footer, the content column's stacking context let the sidebar cover its left half._gacookies.GTM_ID: no script, no banner, no Google address in the policy. Cloudflare's beacon is untouched.Needs doing
GTM_ID= the docs container.analytics_storage, and no Custom HTML tag (the CSP refuses inline script).Checked
task checkandtask lintpass;task exposurepasses.GTM_ID, served locally: before answering, the banner shows and no Google script is in the page; Accept storesgrantedand addsgtm.js; Cookies reopens it; No storesdeniedand pushesanalytics_storage: denied. In a screenshot the banner sits whole over the sidebar.🤖 Generated with Claude Code