# Block Cookies in GTM Triggers with Consent Conditions

> Step-by-step guide to blocking cookies in Google Tag Manager triggers using a custom consent check variable. Ensure GDPR compliance by preventing tags from firing without user consent.

- Canonical: https://support.secureprivacy.ai/article/block-cookies-in-complex-gtm-triggers--consentbased-tagging
- Product: Consent Management
- Category: Integrations
- Published: 2026-03-06T12:43:00+00:00
- Updated: 2026-03-25T01:18:29.12+00:00
- Reading time: 3 minutes

---

When implementing **Google Tag Manager (GTM) consent management**, ensuring that tags and triggers respect **user cookie consent** is essential for **GDPR**, ePrivacy, and other privacy-regulation compliance. This guide walks you through how to **block cookies in GTM triggers** by adding a consent condition — preventing any tag from firing until explicit user consent has been collected by your Consent Management Platform (CMP).

## Who Is This Guide For?

-   **GTM administrators** responsible for tag governance and consent compliance
    
-   **Web developers** implementing tag management and cookie-blocking logic
    
-   **Digital marketers** managing analytics, advertising, and tracking tags under consent requirements
    

## How to Block Cookies in GTM Triggers Based on User Consent

### Step 1: Create a User-Defined Variable for the Consent Check

1.  In GTM, go to **Variables > New**.
    
2.  Name the variable using the format:
    
    ```
    Check [Plugin_name] consent
    ```
    
    **Note on placeholders:** Throughout this guide, `[Plugin_name]` (square brackets) denotes a value you replace with your actual service or plugin name. Do _not_ use double curly braces (`{{ }}`) in variable names or code you author — GTM will interpret that syntax as a live variable reference and fail to resolve it.
    
3.  Set **Variable Type** to **Custom JavaScript**.
    
4.  Enter the following code, replacing `[Plugin_name]` with your exact service name:
    
    ```
    function() {
      return sp.checkConsent("[Plugin_name]");
    }
    ```
    
5.  The plugin name is **case-sensitive** — match it exactly as it appears in your CMP or cookie scan report, for example - for the service "Google Analaytics" it would look like this -
    
    ```
    function() {
      return sp.checkConsent("Google Analaytics");
    }
    ```
    
6.  Save the variable.
    

![GTM Variables panel showing a new Custom JavaScript variable configured for a consent check](https://pub-7bd19505838640d0a08ef1bd6ec3fb9b.r2.dev/articles/8d55336ea644b94e1cc0-f94cc9f75366.webp)

### Step 2: Verify the Plugin Name Matches Your CMP

-   Copy the service or plugin name directly from your cookie scan or CMP dashboard to avoid typos.
    
-   Confirm spelling and capitalisation match exactly — a mismatch will cause the consent check to always return `false`.
    

### Step 3: Add the Consent Condition to Your GTM Trigger

-   Navigate to **Triggers** in GTM.
    
-   Open the trigger you want to gate (e.g., a custom event trigger or click trigger).
    
-   Add a new trigger condition using the variable you created:
    
    ```
    Check [Plugin_name] consent — equals — true
    ```
    
-   This condition ensures the trigger — and any tag attached to it — only fires when the user has granted consent for that specific service.
    

![GTM Trigger configuration panel showing a consent condition added to block tags without user consent](https://pub-7bd19505838640d0a08ef1bd6ec3fb9b.r2.dev/articles/cd3093f35e4f3a465284-a0b7c7f5eb97.webp)

### Step 4: Publish Your GTM Container

Save the trigger and publish your GTM container. Tags governed by this trigger will now **respect user consent**: cookies are blocked and tags remain dormant until the user actively consents through your CMP.

## Frequently Asked Questions

### My tag still fires without consent — what could be wrong?

-   Confirm the plugin name inside `sp.checkConsent("[Plugin_name]")` matches your CMP entry exactly, including capitalisation.
    
-   Verify the Custom JavaScript variable returns a strict boolean `true` or `false` — not a string or undefined value.
    
-   Check that all trigger conditions evaluate to `true` simultaneously; a single failing condition will prevent the trigger from firing correctly.
    
-   Ensure you have not used `{{ }}` double-curly-brace notation in your variable code or name, as GTM will try to resolve this as a built-in variable reference.
    

### How do I test whether the consent condition is working in GTM?

-   Use **GTM Preview Mode** to inspect which triggers fire and which are blocked in real time.
    
-   Toggle consent on and off in your CMP and confirm the tag fires only when consent is granted.
    
-   Check the Variables pane in Preview Mode to confirm your consent variable returns the expected boolean value.
    

## See Also

-   [Implementing Google Consent Mode (Advanced) using Google Tag Manager](https://support.secureprivacy.ai/article/implementing-google-consent-mode-advanced-using-google-tag-manager-community-template)
    
-   [Basic vs. Advanced Google Consent Mode: A Deep Dive into Data Collection](https://support.secureprivacy.ai/article/basic-vs-advanced-google-consent-mode-full-comparison-guide)
    
-   [Ensuring Compliance with Google's EU User Consent Policy](https://support.secureprivacy.ai/article/google-eu-user-consent-policy-compliance-guide--secure-privacy)
