Script gating mode lets you choose how the Google Tag Manager container behaves before consent is granted.
The three modes
- Always load (default). GTM loads on every page. Existing installs keep this behaviour after upgrading to 2.10.
- Load under Consent Mode v2 control. GTM loads on every page, but starts in a denied state via Consent Mode v2. Tags that respect Consent Mode wait until consent is granted. Choose this when you have a CMP that updates Consent Mode and you want analytics to fire pings the moment consent flips, without re-injecting GTM.
- Hold back until consent (strong block). The GTM container script is masked as
text/plainand only executes after consent for the required categories has been granted. Use this when your CMP requires that no Google scripts execute pre-consent.
Required categories for strong block
By default, GTM unmasks once both analytics_storage and ad_storage are granted. To change the required categories from PHP, hook gtmkit_strong_block_required_categories:
add_filter(
'gtmkit_strong_block_required_categories',
static fn(): array => [ 'analytics_storage' ]
);
Notes
- Default
always_loadpreserves pre-2.10 behaviour for every existing install. - In strong-block mode the shim listens for
gtmkit:consent:updatedand re-injects the masked script astext/javascriptonce the threshold is met. Partial updates accumulate viawindow.gtmkit.consent.state, so a CMP firing one category at a time still unblocks correctly. - The shim is scoped to your container ID, so unrelated tools (gtag.js for an Ads pixel, debug inspectors) cannot short-circuit unmask.