Skip to main content

How to Set Default Consent Settings Based on User Consent in GTM ?

When integrating Google Tag Manager (GTM) with the older version of CookieYes(multiple cookies), it is important to make sure that the tags activate based on the user’s consent preferences. To avoid delays in firing tags when the consent level is set at page load, it is important to ensure the consent state is set timely and tags are configured correctly in GTM.

Note

This guide is intended for users of the older version (multiple cookies) of CookieYes.

Step 1: Create a First-Party Cookie Variable.

  1. In the Google Tag Manager Container, navigate to Variables from the left side bar.
  2. Click New to create a User-Defined Variable.

    Create Variable
  3. Choose 1st Party Cookie from the list of variable types.
  4. Name the variable; here, we’ve named analytics_cookie. You can name it according to the category for which you need to retrieve the value.
  5. In the Cookie Name field, enter the name of that cookie i.e. cookieyes-analytics.
analytics cookie

Note

For each category that requires prior consent, create a new first-party cookie with the following names:

  • cookieyes-advertisement
  • cookieyes-functional
  • cookieyes-necessary
  • cookieyes-other
  • cookieyes-performance

Step 2: Create a Custom JavaScript Variable

  1. Create a variable of type Custom JavaScript.

    Custom JavaScript
  2. Name the Custom JavaScript variable. Here, we’ve named cy_analytics for the Analytics Category. Paste the following code into the Custom JavaScript field.
function () {
var c = {{analytics_cookie}} || ""; 
return c.indexOf("yes") === -1 ? "denied" : "granted";
}

Make sure to replace "analytics_cookie" with the name of your first party variable for other categories.

cy analytics

Note

Create a corresponding Custom JavaScript variable for each first-party cookie you create.

Step 3: Configure CookieYes Tag for Default Consent Setting

  1. Navigate to the Tags from the left sidebar and select CookieYes CMP tag.

    CookieYes-CMP
  2. In the default consent settings for each category, specify the custom javascript variable name created earlier. 

    defualt consent gif
  3. Click Save.
  4. Click Submit and then click Publish to implement the changes.

The CookieYes CMP tag has now been configured for default consent settings. This can be done for all the required categories.

Have more questions?

Reach out to us and we'll answer them.

Contact us