Block Third-Party Cookies With Google Tag Manager (GTM)
Last updated on June 5, 2025
On this page
Note:
For blocking third-party cookies with Google Tag Manager in the older version (multiple cookies) of CookieYes, refer to our guide.
Creating a custom event trigger in GTM
Step 1. Create a user-defined variable
- Sign in to your Google Tag Manager account > Click the required Container Name from your Accounts.

- From the left panel, select Variables > In the User-Defined Variables section, click New.

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

Cookies installed by the site — are displayed under the Application tab of the Developer console.
- In the Cookie Name text box, enter the name of the cookie for which you need to retrieve the value. e.g. cookieyes-consent
- Name the variable (here, we’ve named it ‘Analytics’) and click Save to save the variable.

Step 2. Create a custom event trigger
- From the left panel of your GTM account, select Triggers > In the Triggers section, click New.

- Click Trigger Configuration > Choose Custom Event as the trigger type.

- In the Event Name text box, enter cookie_consent_update as shown below and check the Use regex matching option.

Note: For users who have disabled the Support GCM option in CookieYes, please enter the event name as '.*'.
- Under This trigger fires on, choose Some Custom Events.
- Under Fire this trigger when an Event occurs and all of these conditions are true, set up a trigger condition.e.g. Analytics Trigger (i.e. the name of the user-defined variable that you have created in Step 1), contains, and analytics:yes (as shown below).

- Name the Trigger (we’ve named it ‘Analytics Trigger’) and click Save to save the custom event trigger.
Step 3. Add the custom event trigger to the required tag
Step 4: Submit changes
- Click the Submit button at the top right corner of your GTM account.

- Finally, click Publish to make this tag live on your website.

