Repository navigation
WEB-4715 Set Google consent default before Tag Manager loads - #113
Merged
Merged
Conversation
The docs never defined gtag, so cookies.js could not send a consent default and Google Analytics and Clarity ran before the visitor agreed. gtm.html now loads location.js and sets the consent default ahead of Tag Manager: from the cookiePolicy cookie if the visitor made a choice, otherwise denied for EU visitors and granted for others.
SubTachyon
approved these changes
Dec 3, 2026
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.
Fixes WEB-4715: on the docs, Google Analytics cookies (
_ga,_ga_E0VNTED6QB) and Microsoft Clarity ran before the visitor gave cookie consent.Cause:
cookies.jsfrom the main site sends Google consent signals only whenwindow.gtagexists. The docs never definedgtag, so Tag Manager got no consent state and treated every visitor as having agreed.Change:
gtm.htmlloadslocation.js, definesgtag, and sets the consent default before Tag Manager loads. If the visitor already made a choice, the default comes from thecookiePolicycookie (2= analytics,3= ads, as incookies.js). Otherwise it is denied for EU visitors and granted for everyone else.custom-scripts.htmlno longer loadslocation.js, becausegtm.htmlnow loads it in<head>.Tested with the built gdc-cloud-docs output on the live Cloud docs, using the real
cookies.jsand Tag Manager container:_gacookies, no Clarity. Cookies appear after OK; Clarity starts on the next page._gacookies, no Clarity._gaset, ad cookies not set.If
location.jsis blocked,cookies.jstreats the visitor as non-EU and grants consent. That logic is incookies.json the main site, not in this theme.The Python SDK docs use this
gtm.htmltoo. They will get the same consent default when they bump the theme, but they still have no cookie banner.🤖 Generated with Claude Code
Summary by CodeRabbit