Support Google Tag Manager containers and fix consent firing too late - #22
Draft
Alt-Charlie wants to merge 3 commits into
Draft
Support Google Tag Manager containers and fix consent firing too late#22Alt-Charlie wants to merge 3 commits into
Alt-Charlie wants to merge 3 commits into
Conversation
Explains why the addon doesn't output it, and where to put it if you want it anyway. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CkNdE9Q27ZMF14DqZy55En
Alt-Charlie
marked this pull request as draft
July 28, 2026 13:35
Contributor
Author
|
Released as a pre-release candidate for testing first: https://github.com/alt-design/Alt-Cookies-Addon/releases/tag/v1.3.1-alpha |
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.
Resolves #15 and #16.
Tag Manager container support
The Google tab only ever output the gtag.js snippet, which isn't valid for a
GTM-container. The tag ID prefix now picks the right snippet:GTM-gets the full Tag Manager container snippet, everything else (G-,AW-,DC-) keeps gtag.js.Consent was set too late
Consent defaults were pushed on
DOMContentLoaded, by which point the container had already loaded and fired its tags. Tags that aren't consent mode aware (Meta, TikTok) were firing before the visitor chose anything.Defaults are now written synchronously in an inline script immediately before the tag or container loads, derived from the stored
AltCookieAddoncookie so returning visitors don't get a denied-then-granted round trip. The cookie is read in JS rather than PHP so a statically cached page can't bake in one visitor's consent.denyGtagTracking()now bails if that default has already been set, so the DOMContentLoaded path can't push a contradicting secondconsent default.Docs
Require additional consent for tag to firewithad_storagesetting on the tag itself, which we can't reach from outside the container.noscriptiframe isn't output, and where to add it if you want it.Behaviour change worth knowing
Previously the consent default landed after
gtag('config')had already fired, so existing installs were sending an unconsented hit on every page load. That no longer happens, which is correct, but analytics numbers may drop slightly on upgrade.