Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ju1/4c28821b1b8b97ebad272852f0f28e2a to your computer and use it in GitHub Desktop.
Save ju1/4c28821b1b8b97ebad272852f0f28e2a to your computer and use it in GitHub Desktop.
GDPR Cookie Consent Notification Recipe Patch for Google Tag Manager (2018 June 14th)
{
"exportFormatVersion": 2,
"exportTime": "2018-06-14 13:05:51",
"containerVersion": {
"path": "accounts/1164259306/containers/9256170/versions/0",
"accountId": "1164259306",
"containerId": "9256170",
"containerVersionId": "0",
"container": {
"path": "accounts/1164259306/containers/9256170",
"accountId": "1164259306",
"containerId": "9256170",
"name": "GDPR Cookie Consent Notification Recipe Patch",
"publicId": "GTM-KJNS2BH",
"usageContext": [
"WEB"
],
"fingerprint": "1528981427098",
"tagManagerUrl": "https://tagmanager.google.com/#/container/accounts/1164259306/containers/9256170/workspaces?apiLink=container"
},
"tag": [
{
"accountId": "1164259306",
"containerId": "9256170",
"tagId": "1",
"name": "cHTML - Set Cookie - Actual Cookie Consent Active Groups",
"type": "html",
"notes": "Default Cookie set by Onetrust is out of date, if the user changes the consent, the cookie still remains the same. So I read the Data Layer and store the latest consent value in the cookie",
"parameter": [
{
"type": "TEMPLATE",
"key": "html",
"value": "<script>\n \n var cookieName = \"actualOptanonConsent\"; \n var cookieValue = encodeURIComponent({{dlv - Active Consent Groups}});\n var expirationTime = 31536000; // One year in seconds\n expirationTime = expirationTime * 1000; // Converts expirationtime to milliseconds\n var date = new Date(); \n var dateTimeNow = date.getTime(); \n\n date.setTime(dateTimeNow + expirationTime);\n var expirationTime = date.toUTCString();\n document.cookie = cookieName+\"=\"+cookieValue+\"; expires=\"+expirationTime+\"; path=/; domain=.\" + location.hostname.replace(/^www\\./i, \"\"); \n\n</script>"
},
{
"type": "BOOLEAN",
"key": "supportDocumentWrite",
"value": "false"
}
],
"fingerprint": "1528981427098",
"tagFiringOption": "ONCE_PER_EVENT"
}
],
"variable": [
{
"accountId": "1164259306",
"containerId": "9256170",
"variableId": "1",
"name": "Cookie - Actual Cookie Consent",
"type": "k",
"parameter": [
{
"type": "BOOLEAN",
"key": "decodeCookie",
"value": "true"
},
{
"type": "TEMPLATE",
"key": "name",
"value": "actualOptanonConsent"
}
],
"fingerprint": "1528981426886"
}
],
"builtInVariable": [
{
"accountId": "1164259306",
"containerId": "9256170",
"type": "PAGE_URL",
"name": "Page URL"
},
{
"accountId": "1164259306",
"containerId": "9256170",
"type": "PAGE_HOSTNAME",
"name": "Page Hostname"
},
{
"accountId": "1164259306",
"containerId": "9256170",
"type": "PAGE_PATH",
"name": "Page Path"
},
{
"accountId": "1164259306",
"containerId": "9256170",
"type": "REFERRER",
"name": "Referrer"
},
{
"accountId": "1164259306",
"containerId": "9256170",
"type": "EVENT",
"name": "Event"
}
],
"fingerprint": "0",
"tagManagerUrl": "https://tagmanager.google.com/#/versions/accounts/1164259306/containers/9256170/versions/0?apiLink=version"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment