For the complete documentation index, see llms.txt. This page is also available as Markdown.

Optimize GTM Web

Loading the GTM Web script from the server-side host

One of the main advantages of Sirdata's server-side infrastructure is the ability to load the Google Tag Manager (GTM) Web script directly from your server-side host. This method allows you to:

  • Bypass ad blockers that traditionally block GTM scripts

  • Bypass Safari private browsing restrictions on iOS, which limit third-party tracking

Available optimization options

When loading GTM Web from the server-side host, several optimization options are available:

1. Loading the CMP from the GTM script

This option loads the CMP (Consent Management Platform) directly from the GTM Web script, which optimizes Consent Mode. Consent signals are available earlier in the page lifecycle, improving the accuracy of tag conditioning.

2. DataLayer reordering

This option optimizes event sequences in the dataLayer. By reordering dataLayer entries before GTM initialization, it ensures that:

  • Data declarations come first

  • CMP consent events are processed before tag triggers

  • The gtm.js start signal is correctly positioned

This notably prevents "Not Set" data issues in GA4, which occur when tags fire before configuration variables are available.

This option delays GTM execution until the user's consent choice is known (either retrieved from a previous session or after an explicit user action on the CMP).

The trade-off: a slight delay in GTM execution. Since the GTM script is preloaded (<link rel="preload">), the execution delay after the consent signal is negligible.

The immense advantage: when GTM executes after the consent choice is known, tag conditioning is greatly simplified. You can simply use the built-in tag conditioning, based on Google Consent Mode V2.

Configuration in GTM

In GTM, go to your tag configuration, then in the Consent Settings (BETA) section → Additional Consent Checks → select Require additional consent for tag to fire.

GTM consent settings configuration

You can specify the required consents, for example:

  • ad_storage — required for advertising tags

  • ad_personalization — required for ad personalization

You can add additional conditions as needed.

⚠️ Important warning

Mis à jour