___INFO___ { "type": "TAG", "id": "mayicookies-cmp", "version": 1, "displayName": "mayicookies CMP", "description": "Sets Google Consent Mode v2 defaults and updates consent from mayicookies.", "brand": { "id": "mayicookies", "displayName": "mayicookies" } } ___TEMPLATE_PARAMETERS___ [ { "type": "TEXT", "name": "cookieName", "displayName": "Consent cookie name", "simpleValueType": true, "defaultValue": "mayicookies_gtm_consent", "valueValidators": [ { "type": "NON_EMPTY" } ], "help": "Must match the cookie name allowed in template permissions. The import grants access to mayicookies_gtm_consent." }, { "type": "TEXT", "name": "waitForUpdate", "displayName": "wait_for_update milliseconds", "simpleValueType": true, "defaultValue": 500 }, { "type": "TEXT", "name": "region", "displayName": "Region codes", "simpleValueType": true, "help": "Optional comma-separated ISO 3166-2 country codes, for example DE,FR,US-CA." }, { "type": "CHECKBOX", "name": "adsDataRedaction", "checkboxText": "Enable ads_data_redaction", "simpleValueType": true, "defaultValue": true }, { "type": "CHECKBOX", "name": "urlPassthrough", "checkboxText": "Enable url_passthrough", "simpleValueType": true, "defaultValue": false }, { "type": "TEXT", "name": "developerId", "displayName": "Google developer ID", "simpleValueType": true, "help": "Optional Google CMP developer ID. Leave blank unless Google assigned one." } ] ___SANDBOXED_JS_FOR_WEB_TEMPLATE___ const setDefaultConsentState = require('setDefaultConsentState'); const updateConsentState = require('updateConsentState'); const getCookieValues = require('getCookieValues'); const callInWindow = require('callInWindow'); const gtagSet = require('gtagSet'); const JSON = require('JSON'); const cookieName = data.cookieName || 'mayicookies_gtm_consent'; const waitForUpdate = data.waitForUpdate || 500; const defaultConsentState = { ad_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied', analytics_storage: 'denied', functionality_storage: 'denied', personalization_storage: 'denied', security_storage: 'granted', wait_for_update: waitForUpdate, }; if (data.region) { defaultConsentState.region = data.region.split(',').map(function(region) { return region.trim(); }).filter(function(region) { return region; }); } if (data.adsDataRedaction !== false) { gtagSet('ads_data_redaction', true); } if (data.urlPassthrough === true) { gtagSet('url_passthrough', true); } if (data.developerId) { const developerIds = {}; developerIds[data.developerId] = true; gtagSet('developer_id', developerIds); } setDefaultConsentState(defaultConsentState); function normalizeConsentState(state) { return { ad_storage: state.ad_storage === 'granted' ? 'granted' : 'denied', ad_user_data: state.ad_user_data === 'granted' ? 'granted' : 'denied', ad_personalization: state.ad_personalization === 'granted' ? 'granted' : 'denied', analytics_storage: state.analytics_storage === 'granted' ? 'granted' : 'denied', functionality_storage: state.functionality_storage === 'granted' ? 'granted' : 'denied', personalization_storage: state.personalization_storage === 'granted' ? 'granted' : 'denied', security_storage: state.security_storage === 'denied' ? 'denied' : 'granted', }; } function updateFromCookie() { const values = getCookieValues(cookieName); if (!values || !values.length) return; updateConsentState(normalizeConsentState(JSON.parse(values[0]))); } // Stored Google flags are not proof of a current policy choice. Only the SDK // may restore grants after validating configuration, age and live GPC. callInWindow('mayicookiesAddConsentModeListener', function(state) { updateConsentState(normalizeConsentState(state || {})); }); data.gtmOnSuccess(); ___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": false }, { "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": false }, { "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": false }, { "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": false }, { "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": false }, { "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": false }, { "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": false }, { "type": 8, "boolean": true } ] }, { "type": 3, "mapKey": [ { "type": 1, "string": "consentType" }, { "type": 1, "string": "read" }, { "type": 1, "string": "write" } ], "mapValue": [ { "type": 1, "string": "wait_for_update" }, { "type": 8, "boolean": false }, { "type": 8, "boolean": true } ] } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true }, { "instance": { "key": { "publicId": "get_cookies", "versionId": "1" }, "param": [ { "key": "cookieAccess", "value": { "type": 1, "string": "any" } } ] }, "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": "mayicookiesAddConsentModeListener" }, { "type": 8, "boolean": true }, { "type": 8, "boolean": false }, { "type": 8, "boolean": true } ] } ] } } ] }, "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" }, { "type": 1, "string": "developer_id" }, { "type": 1, "string": "developer_id.*" } ] } } ] }, "clientAnnotations": { "isEditedByUser": true }, "isRequired": true } ]