___TERMS_OF_SERVICE___ By creating or modifying this file you agree to Google Tag Manager's Community Template Gallery Developer Terms of Service available at https://developers.google.com/tag-manager/gallery-tos (or such other URL as Google may provide), as modified from time to time. ___INFO___ { "type": "TAG", "id": "cvt_temp_public_id", "version": 1, "securityGroups": [], "displayName": "consent.link — Consent Mode", "categories": [ "UTILITY" ], "brand": { "id": "brand_dummy", "displayName": "consent.link" }, "description": "Sets the Google Consent Mode v2 default and applies the visitor's decision from a consent.link link (the cl_ct token). Fire it on Consent Initialization - All Pages.", "containerContexts": [ "WEB" ] } ___TEMPLATE_PARAMETERS___ [ { "type": "TEXT", "name": "waitForUpdate", "displayName": "Wait for update (milliseconds)", "simpleValueType": true, "defaultValue": "500", "valueValidators": [ { "type": "NON_NEGATIVE_NUMBER" } ] } ] ___SANDBOXED_JS_FOR_WEB_TEMPLATE___ const setDefaultConsentState = require('setDefaultConsentState'); const updateConsentState = require('updateConsentState'); const getCookieValues = require('getCookieValues'); const injectScript = require('injectScript'); const getTimestampMillis = require('getTimestampMillis'); const makeNumber = require('makeNumber'); const JSON = require('JSON'); const SIGNALS = {"stats":["analytics_storage"],"ads":["ad_storage","ad_user_data","ad_personalization"],"app_install":["ad_storage","ad_user_data"],"personalization":["personalization_storage"]}; const ALL = ["ad_storage","ad_user_data","ad_personalization","analytics_storage","personalization_storage","functionality_storage","security_storage"]; const ALWAYS = ["functionality_storage","security_storage"]; function state(decision, purposes) { const s = {}; ALL.forEach(function (k) { s[k] = ALWAYS.indexOf(k) === -1 ? 'denied' : 'granted'; }); if (decision === 'granted') { purposes.forEach(function (p) { (SIGNALS[p] || []).forEach(function (k) { s[k] = 'granted'; }); }); } return s; } const initial = state('denied', []); initial.wait_for_update = makeNumber(data.waitForUpdate || 500); setDefaultConsentState(initial); // A decision this browser already brought from a consent.link page. const stored = getCookieValues("cl_consent")[0]; if (stored) { const v = JSON.parse(stored); if (v && (v.d === 'granted' || v.d === 'denied') && v.p && v.e && v.e * 1000 > getTimestampMillis()) { updateConsentState(state(v.d, v.p)); } } // The script checks a fresh cl_ct token and applies it. injectScript("https://consent.link/js/consent.js?gtm=1", data.gtmOnSuccess, data.gtmOnFailure, 'consent-link'); ___WEB_PERMISSIONS___ [ { "instance": { "key": { "publicId": "access_consent", "versionId": "1" }, "param": [ { "key": "consentTypes", "value": { "type": 2, "listItem": [ { "type": 3, "mapKey": [ { "type": 1, "string": "consentType" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" } ], "mapValue": [ { "type": 1, "string": "ad_storage" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": true } ] }, { "type": 3, "mapKey": [ { "type": 1, "string": "consentType" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" } ], "mapValue": [ { "type": 1, "string": "ad_user_data" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": true } ] }, { "type": 3, "mapKey": [ { "type": 1, "string": "consentType" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" } ], "mapValue": [ { "type": 1, "string": "ad_personalization" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": true } ] }, { "type": 3, "mapKey": [ { "type": 1, "string": "consentType" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" } ], "mapValue": [ { "type": 1, "string": "analytics_storage" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": true } ] }, { "type": 3, "mapKey": [ { "type": 1, "string": "consentType" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" } ], "mapValue": [ { "type": 1, "string": "personalization_storage" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": true } ] }, { "type": 3, "mapKey": [ { "type": 1, "string": "consentType" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" } ], "mapValue": [ { "type": 1, "string": "functionality_storage" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": true } ] }, { "type": 3, "mapKey": [ { "type": 1, "string": "consentType" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" } ], "mapValue": [ { "type": 1, "string": "security_storage" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": true } ] } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true }, { "instance": { "key": { "publicId": "get_cookies", "versionId": "1" }, "param": [ { "key": "cookieAccess", "value": { "type": 1, "string": "specific" } }, { "key": "cookieNames", "value": { "type": 2, "listItem": [ { "type": 1, "string": "cl_consent" } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true }, { "instance": { "key": { "publicId": "inject_script", "versionId": "1" }, "param": [ { "key": "urls", "value": { "type": 2, "listItem": [ { "type": 1, "string": "https://consent.link/js/consent.js?gtm=1" } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true } ] ___TESTS___ scenarios: [] ___NOTES___ consent.link: https://consent.link/faq/api#site. Fire on "Consent Initialization - All Pages", before any Google tag.