Skip to content

Support Google Tag Manager containers and fix consent firing too late - #22

Draft
Alt-Charlie wants to merge 3 commits into
masterfrom
DEV-5292
Draft

Support Google Tag Manager containers and fix consent firing too late#22
Alt-Charlie wants to merge 3 commits into
masterfrom
DEV-5292

Conversation

@Alt-Charlie

Copy link
Copy Markdown
Contributor

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 AltCookieAddon cookie 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 second consent default.

Docs

  • Google Tag ID field explains which ID types are accepted.
  • README covers the Tag Manager side of this: third party tags in a container still need Require additional consent for tag to fire with ad_storage setting on the tag itself, which we can't reach from outside the container.
  • README explains why the noscript iframe 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.

Alt-Charlie and others added 2 commits July 28, 2026 14:16
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
Alt-Charlie marked this pull request as draft July 28, 2026 13:35
@Alt-Charlie

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pixels firing before DOMContentLoaded

1 participant