Created
June 10, 2021 21:33
-
-
Save mbaersch/dae0e946cae78f4106f52674778b2066 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
___INFO___ | |
{ | |
"type": "TAG", | |
"id": "cvt_temp_public_id", | |
"version": 1, | |
"securityGroups": [], | |
"displayName": "Consent Mode Configuration (Demo)", | |
"brand": { | |
"id": "brand_dummy", | |
"displayName": "" | |
}, | |
"description": "Demo code for a GTM Consent Mode Tag Template. Allows setting (hard coded) default consent state or translates two specific One Trust group consents to Consent Mode consent state updates.", | |
"containerContexts": [ | |
"WEB" | |
] | |
} | |
___TEMPLATE_PARAMETERS___ | |
[ | |
{ | |
"type": "SELECT", | |
"name": "cmType", | |
"displayName": "", | |
"macrosInSelect": false, | |
"selectItems": [ | |
{ | |
"value": "default", | |
"displayValue": "Set Default Permissions" | |
}, | |
{ | |
"value": "update_onetrust", | |
"displayValue": "Update Permissions (One Trust)" | |
} | |
], | |
"simpleValueType": true | |
} | |
] | |
___SANDBOXED_JS_FOR_WEB_TEMPLATE___ | |
const setDefaultConsentState = require('setDefaultConsentState'); | |
const updateConsentState = require('updateConsentState'); | |
const copyFromDataLayer = require('copyFromDataLayer'); | |
var mode = data.cmType; | |
//set consent state defaults. | |
//hardcoded: everything (including sample consents) is denied, | |
//example tag type "mbsl_logger" and security_storage are "on" by default | |
if (mode === "default") | |
setDefaultConsentState({ | |
google_analytics: 'denied', | |
facebook: 'denied', | |
mbsl_logger: 'granted', | |
ad_storage: 'denied', | |
analytics_storage: 'denied', | |
functional_storage: 'denied', | |
personalization_storage: 'denied', | |
security_storage: 'granted' | |
}); | |
else if (mode === "update_onetrust") { | |
//read One Trust consent settings (here: group consents) from dataLayer | |
//change code here, if a different dataLayer attribute or a cookie is used and | |
var consentString = copyFromDataLayer('OptanonActiveGroups') || ""; | |
//"translate" dataLayer group consents to consent settings for Facebook (C0004 in this example) | |
//and GA (C0002) and update consent state accordingly | |
var ga_cns = (consentString.indexOf(',C0002,') >= 0) ? 'granted' : 'denied'; | |
var fb_cns = (consentString.indexOf(',C0003,') >= 0) ? 'granted' : 'denied'; | |
updateConsentState({ | |
google_analytics: ga_cns, | |
facebook: fb_cns, | |
mbsl_logger: 'granted', | |
ad_storage: 'denied', | |
analytics_storage: 'denied', | |
functional_storage: 'denied', | |
personalization_storage: 'denied', | |
security_storage: 'granted' | |
}); | |
} | |
data.gtmOnSuccess(); | |
___WEB_PERMISSIONS___ | |
[ | |
{ | |
"instance": { | |
"key": { | |
"publicId": "read_data_layer", | |
"versionId": "1" | |
}, | |
"param": [ | |
{ | |
"key": "keyPatterns", | |
"value": { | |
"type": 2, | |
"listItem": [ | |
{ | |
"type": 1, | |
"string": "OptanonActiveGroups" | |
} | |
] | |
} | |
} | |
] | |
}, | |
"clientAnnotations": { | |
"isEditedByUser": true | |
}, | |
"isRequired": true | |
}, | |
{ | |
"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": "functional_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 | |
} | |
] | |
}, | |
{ | |
"type": 3, | |
"mapKey": [ | |
{ | |
"type": 1, | |
"string": "consentType" | |
}, | |
{ | |
"type": 1, | |
"string": "read" | |
}, | |
{ | |
"type": 1, | |
"string": "write" | |
} | |
], | |
"mapValue": [ | |
{ | |
"type": 1, | |
"string": "google_analytics" | |
}, | |
{ | |
"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": "facebook" | |
}, | |
{ | |
"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": "mbsl_logger" | |
}, | |
{ | |
"type": 8, | |
"boolean": true | |
}, | |
{ | |
"type": 8, | |
"boolean": true | |
} | |
] | |
} | |
] | |
} | |
} | |
] | |
}, | |
"clientAnnotations": { | |
"isEditedByUser": true | |
}, | |
"isRequired": true | |
} | |
] | |
___TESTS___ | |
scenarios: [] | |
___NOTES___ | |
Created on 10.6.2021, 23:31:36 | |
Author
mbaersch
commented
Jun 10, 2021
Info zum Beispielcode und dem Einsatz im GTM, den hier benutzten "Custom Consent State Settings" und der Übersetzung der Einstellungen aus One Trust zu Consent Mode im Blog unter https://www.markus-baersch.de/blog/neue-consent-mode-features-im-google-tag-manager-zur-trigger-reduktion-nutzen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment