# Block Third-Party Cookies With Tag Manager (GTM)

If you use Google Tag Manager to add third-party scripts to your website, learn how to block cookies with GTM & CookieYes before user consent.

---

**Categories:** , 
**Published:** July 30, 2026
**URL:** https://www.cookieyes.com/documentation/block-third-party-cookies-with-google-tag-manager-gtm-old-version/

---

CookieYes automatically blocks third-party cookies on your website prior to obtaining user consent. However, if you're using [Google Tag Manager](https://tagmanager.google.com/) to add third-party scripts to your website, you may want to block cookies set via GTM that have not been consented to use. For this, you will have to create an appropriate custom event trigger in your GTM account. Here’s an example of blocking third-party cookies with Google Tag Manager.

> For blocking third-party cookies with google tag manager in the new version(Single Cookie) of CookiesYes refer to our [guide](https://www.cookieyes.com/documentation/block-third-party-cookies-with-google-tag-manager-and-cookieyes).
>

## Creating a custom event trigger in GTM

The following are the steps to create a custom event trigger in Google Tag Manager that helps CookieYes block third-party cookie scripts on your website (set via GTM) prior to receiving user consent.
For better understanding, throughout this guide, let’s consider the case of blocking a Functional cookie script (added to your GTM account) until you obtain user consent.

## Step 1: Create a user-defined variable

1. Sign in to your Google Tag Manager account > Click the required **Container*** ***Name** from your **Accounts**.
2. From the left panel, select **Variables** > In the **User-Defined Variables** section, click **New**.
![variables.png](https://assets.cookieyes.com/variables_f6d4f862b7.png)
3. Click **Variable Configuration** > Choose variable type as **1st Party Cookie** from under **Page Variables**.
> **Note:**
>  1st Party Cookie variable allows Google Tag Manager to access the first-party cookies created by your website.
![inspect wth 1st party cookies.png](https://assets.cookieyes.com/inspect_wth_1st_party_cookies_d7f35cc608.png)
4. In the Cookie Name text box, enter the name of that cookie for which you need to retrieve the value. E.g. *cookieyes-functional*
5. Name the variable (here, we’ve named it ‘Live Chat Trigger Variable’) and click **Save** to save the variable.
![cookieyes functional naming cookie variable.png](https://assets.cookieyes.com/cookieyes_functional_naming_cookie_variable_3e5755f155.png)

## Step 2: Create a custom event trigger

1. From the left panel of your GTM account, select **Triggers** > In the Triggers section, click **New**.
![trigger.png](https://assets.cookieyes.com/trigger_1e41f14b99.png)
2. Click **Trigger Configuration** > Choose** Custom Event **as the trigger type.
![custom-event.png](https://assets.cookieyes.com/custom_event_cc41136b31.png)
3. In the Event Name text box, enter **.*** as shown below and check the **Use regex matching** option.
![naming trigger event.png](https://assets.cookieyes.com/naming_trigger_event_8101f3de11.png)
4. Under **This trigger fires on**, choose **Some Custom Events**.
5. Under *Fire this trigger when an Event occurs and all of these conditions are true*, set up a trigger condition.
*e.g. Live Chat Trigger Variable (i.e. the ****name of the user-defined variable**** that you have created in Step 1), ****equals****, and ****yes**** (as shown below)*
![google-tag-manager-trigger-condiiton-save-trigger-name.png](https://assets.cookieyes.com/google_tag_manager_trigger_condiiton_save_trigger_name_7624d6f48f.png)
6. Name the Trigger (we’ve named it ‘Live Chat Trigger’) and click **Save** to save the custom event trigger.

## Step 3: Add the custom event trigger to the required custom HTML tag

1. From the left panel of your GTM account, select **Tags** > Click the Tag name that needs to be fired.
![google-tag-manager-open-tag.png](https://assets.cookieyes.com/google_tag_manager_open_tag_588f62ddef.png)
2. Click **Triggering**.
![google-tag-manager-clikc-to-add-tag.png](https://assets.cookieyes.com/google_tag_manager_clikc_to_add_tag_18eb6db544.png)
3. Choose the custom event trigger that you have created in *Step 2*.
![google-tag-manager-choose-live-chat-trigger.png](https://assets.cookieyes.com/google_tag_manager_choose_live_chat_trigger_8cfaa59b1d.png)
4. Click Save.
![google-tag-manager-click-save-to-save-the-tag-trigger.png](https://assets.cookieyes.com/google_tag_manager_click_save_to_save_the_tag_trigger_3d49e78f64.png)

## Step 4: Submit changes

1. Click the **Submit** button at the top right corner of your GTM account.
![google-tag-manager-submit-tag.png](https://assets.cookieyes.com/google_tag_manager_submit_tag_226c55c5ce.png)
2. Finally, click **Publish** to make this tag live on your website.
![google-tag-manager-publish-the-tag.png](https://assets.cookieyes.com/google_tag_manager_publish_the_tag_e1624dc10e.png)

Once you have done these steps, your site visitors will not have Functional cookies running in the background after enabling Analytics cookies and disabling Functional cookies.
Now, take a look at your website’s active cookies before and after adding the custom event trigger in GTM.

![Website](https://assets.cookieyes.com/google_tag_manager_website_and_inspect_element_before_adding_custom_event_trigger_1024x543_x0s6_0aea8e2e02.png)

Before adding the custom event trigger in GTM

![Website](https://assets.cookieyes.com/google_tag_manager_website_and_inspect_element_after_adding_custom_event_trigger_1024x543_mza2_6fe21c9795.png)

After adding the custom event trigger in GTM

This is how you can block cookies with Google Tag Manager.


---

## Structured Data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Article",
      "headline": "Block Third-Party Cookies With Tag Manager (GTM)",
      "mainEntityOfPage": {
        "@type": "WebPage",
        "@id": "https://www.cookieyes.com/documentation/block-third-party-cookies-with-google-tag-manager-gtm-old-version/"
      },
      "url": "https://www.cookieyes.com/documentation/block-third-party-cookies-with-google-tag-manager-gtm-old-version/",
      "publisher": {
        "@type": "Organization",
        "name": "CookieYes",
        "url": "https://www.cookieyes.com",
        "logo": {
          "@type": "ImageObject",
          "url": "https://assets.cookieyes.com/cookieyes.png",
          "width": 250,
          "height": 60
        }
      },
      "description": "If you use Google Tag Manager to add third-party scripts to your website, learn how to block cookies with GTM & CookieYes before user consent.",
      "datePublished": "2022-10-06T14:56:05+00:00",
      "dateModified": "2026-03-09T00:00:00+00:00",
      "author": {
        "@type": "Person",
        "name": "CookieYes Doc Team"
      },
      "image": [
        "https://assets.cookieyes.com/Block_cookies_with_Google_Tag_Manager_1_id8i_8b8d1454f9.png"
      ]
    },
    {
      "@type": "BreadcrumbList",
      "@id": "https://www.cookieyes.com/documentation/block-third-party-cookies-with-google-tag-manager-gtm-old-version/#breadcrumb",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://www.cookieyes.com/"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Documentation",
          "item": "https://www.cookieyes.com/documentation/"
        },
        {
          "@type": "ListItem",
          "position": 3,
          "name": "Features Documentation",
          "item": "https://www.cookieyes.com/category/documentation/features/"
        },
        {
          "@type": "ListItem",
          "position": 4,
          "name": "Google Consent Mode",
          "item": "https://www.cookieyes.com/category/documentation/features/google-consent-mode/"
        },
        {
          "@type": "ListItem",
          "position": 5,
          "name": "Block Third-Party Cookies With Tag Manager (GTM)"
        }
      ]
    },
    {
      "@type": "WebSite",
      "@id": "https://www.cookieyes.com/#website",
      "url": "https://www.cookieyes.com/",
      "name": "CookieYes",
      "description": "CookieYes is a Google-certified consent management platform that helps businesses comply with GDPR, CCPA, and other global privacy laws.",
      "inLanguage": "en-US",
      "publisher": {
        "@id": "https://www.cookieyes.com/#organization"
      },
      "potentialAction": {
        "@type": "SearchAction",
        "target": {
          "@type": "EntryPoint",
          "urlTemplate": "https://www.cookieyes.com/?s={search_term_string}"
        },
        "query-input": {
          "@type": "PropertyValueSpecification",
          "valueRequired": true,
          "valueName": "search_term_string"
        }
      }
    },
    {
      "@type": "Organization",
      "@id": "https://www.cookieyes.com/#organization",
      "name": "CookieYes",
      "url": "https://www.cookieyes.com/",
      "logo": {
        "@type": "ImageObject",
        "@id": "https://www.cookieyes.com/#/schema/logo/image/",
        "inLanguage": "en-US",
        "url": "https://assets.cookieyes.com/cookieyes.png",
        "contentUrl": "https://assets.cookieyes.com/cookieyes.png",
        "width": 19701,
        "height": 3176,
        "caption": "CookieYes"
      },
      "image": {
        "@id": "https://www.cookieyes.com/#/schema/logo/image/"
      }
    }
  ]
}
```
