___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": "ConsentCDN – Banner de cookies y Consent Mode", "categoryIds": [ "TAG_MANAGEMENT", "UTILITY" ], "brand": { "id": "brand_dummy", "displayName": "ConsentCDN" }, "description": "Banner de consentimiento de cookies con Google Consent Mode v2. Fija el consentimiento por defecto (denegado) en «Inicialización del consentimiento», recupera la decisión guardada del visitante y carga el banner de consentcdn.es. Úsala con el activador «Consent Initialization - All Pages».", "containerContexts": [ "WEB" ] } ___TEMPLATE_PARAMETERS___ [ { "type": "TEXT", "name": "token", "displayName": "Código de la web (token)", "simpleValueType": true, "help": "El código de la huella de esta web en el panel (lo verás en «Instalación»).", "valueValidators": [ { "type": "NON_EMPTY" }, { "type": "REGEX", "args": [ "^[A-Za-z0-9]{12,64}$" ] } ] }, { "type": "CHECKBOX", "name": "soloEee", "checkboxText": "Denegar por defecto solo en el EEE, Reino Unido y Suiza (en el resto, concedido)", "simpleValueType": true, "defaultValue": false, "help": "Déjalo sin marcar si la web se dirige a España o a la UE: el consentimiento empezará denegado para todos." }, { "type": "CHECKBOX", "name": "adsRedaction", "checkboxText": "Ocultar datos publicitarios mientras no se acepte (ads_data_redaction)", "simpleValueType": true, "defaultValue": true }, { "type": "CHECKBOX", "name": "urlPassthrough", "checkboxText": "Pasar los identificadores de clic por la URL (url_passthrough)", "simpleValueType": true, "defaultValue": false }, { "type": "TEXT", "name": "waitForUpdate", "displayName": "Espera a la actualización (ms)", "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 setInWindow = require('setInWindow'); const gtagSet = require('gtagSet'); const encodeUriComponent = require('encodeUriComponent'); const makeInteger = require('makeInteger'); const EEE = ['AT','BE','BG','HR','CY','CZ','DK','EE','FI','FR','DE','GR','HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','RO','SK','SI','ES','SE','IS','LI','NO','GB','CH']; const espera = makeInteger(data.waitForUpdate || 500); const denegado = { ad_storage: 'denied', analytics_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied', functionality_storage: 'denied', personalization_storage: 'denied', security_storage: 'granted', wait_for_update: espera }; if (data.soloEee) { denegado.region = EEE; setDefaultConsentState(denegado); setDefaultConsentState({ ad_storage: 'granted', analytics_storage: 'granted', ad_user_data: 'granted', ad_personalization: 'granted', functionality_storage: 'granted', personalization_storage: 'granted', security_storage: 'granted' }); } else { setDefaultConsentState(denegado); } if (data.adsRedaction) gtagSet('ads_data_redaction', true); if (data.urlPassthrough) gtagSet('url_passthrough', true); // Decisión ya guardada: se aplica antes de que se disparen las etiquetas. const leer = (n) => { const v = getCookieValues(n); return v && v.length ? v[0] : undefined; }; if (leer('ccdn') || leer('cookiebar_icon') === 'Icon') { const s = (n) => leer(n) === 'CookieAllowed' ? 'granted' : 'denied'; updateConsentState({ analytics_storage: s('cookiebar_analiticas'), ad_storage: s('cookiebar_marketing'), ad_user_data: s('cookiebar_marketing'), ad_personalization: s('cookiebar_publicidad2'), functionality_storage: s('cookiebar_funcionalidad'), personalization_storage: s('cookiebar_funcionalidad') }); } // El banner sabe así que el consentimiento por defecto ya está puesto. setInWindow('__ccdn_gtm', true, true); injectScript('https://consentcdn.es/b/' + encodeUriComponent(data.token) + '.js', data.gtmOnSuccess, data.gtmOnFailure, 'ccdn'); ___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": "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": "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": "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": "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": "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": "ccdn" }, { "type": 1, "string": "cookiebar_icon" }, { "type": 1, "string": "cookiebar_analiticas" }, { "type": 1, "string": "cookiebar_marketing" }, { "type": 1, "string": "cookiebar_publicidad2" }, { "type": 1, "string": "cookiebar_funcionalidad" } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true }, { "instance": { "key": { "publicId": "inject_script", "versionId": "1" }, "param": [ { "key": "urls", "value": { "type": 2, "listItem": [ { "type": 1, "string": "https://consentcdn.es/*" } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true }, { "instance": { "key": { "publicId": "access_globals", "versionId": "1" }, "param": [ { "key": "keys", "value": { "type": 2, "listItem": [ { "type": 3, "mapKey": [ { "type": 1, "string": "key" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" }, { "type": 1, "string": "execute" } ], "mapValue": [ { "type": 1, "string": "__ccdn_gtm" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": true }, { "type": 8, "boolean": false } ] } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true }, { "instance": { "key": { "publicId": "write_data_layer", "versionId": "1" }, "param": [ { "key": "keyPatterns", "value": { "type": 2, "listItem": [ { "type": 1, "string": "ads_data_redaction" }, { "type": 1, "string": "url_passthrough" } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true } ] ___TESTS___ scenarios: - name: Consentimiento por defecto denegado y banner cargado code: |- const mockData = {token: 'ofw8ilvcxzrksh0tqun95m76ejba3gy21pd4', soloEee: false, adsRedaction: true, urlPassthrough: false, waitForUpdate: '500'}; mock('injectScript', (url, ok) => { assertThat(url).isEqualTo('https://consentcdn.es/b/ofw8ilvcxzrksh0tqun95m76ejba3gy21pd4.js'); ok(); }); runCode(mockData); assertApi('setDefaultConsentState').wasCalled(); assertApi('updateConsentState').wasNotCalled(); assertApi('gtmOnSuccess').wasCalled(); - name: Decisión guardada se aplica antes de las etiquetas code: |- const mockData = {token: 'ofw8ilvcxzrksh0tqun95m76ejba3gy21pd4', soloEee: false, adsRedaction: true, urlPassthrough: false, waitForUpdate: '500'}; mock('getCookieValues', (n) => n === 'ccdn' ? ['abc.1.1'] : (n === 'cookiebar_analiticas' ? ['CookieAllowed'] : ['NotAllowed'])); mock('injectScript', (url, ok) => ok()); runCode(mockData); assertApi('updateConsentState').wasCalled(); assertApi('gtmOnSuccess').wasCalled(); ___NOTES___ Created on 15/11/2026 by ConsentCDN (Cookies Marca Blanca).