> For the complete documentation index, see [llms.txt](https://server-side.docs.sirdata.net/sirdata-server-side/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://server-side.docs.sirdata.net/sirdata-server-side/english-1/installation/optimize-gtm-web.md).

# 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.

### 3. Load GTM after consent choice is known

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).

<figure><img src="/files/YzSRe0UBwuDNYFvb3sp1" alt=""><figcaption></figcaption></figure>

**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](/files/mW1bJhPNyeJunImqM86O)

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.

{% hint style="warning" %}

## ⚠️ Important warning

**This method is ONLY effective with:**

* Sirdata CMP
* sGTM hosted by Sirdata

**Using it with another CMP or another sGTM offering may block all tag firings**, as the necessary consent signals would not be available when GTM executes.
{% endhint %}
