Instantly share code, notes, and snippets.
humanswitchsupport
/ GTM ConsentCookie tag
Last active
October 24, 2018 14:43
ConsentCookie GoogleTagManager based on consentcookie cookie settings
This file contains 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
<script> | |
(function(window) { | |
var consentcookiecookie = {{consentcookiecookie}}; | |
var clist = consentcookiecookie.split('&'); | |
var consents = {}; | |
for (x in clist){ | |
var str = clist[x].split('='); | |
consents[str[0]] = str[1]; | |
}; | |
//console.log(consents) |
humanswitchsupport
/ DemoPage ConsentCookie
Created
May 7, 2018 14:40
This file contains 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
<!-- | |
~ Copyright 2018 Asknow Solutions B.V. | |
~ | |
~ Licensed under the Apache License, Version 2.0 (the "License"); | |
~ you may not use this file except in compliance with the License. | |
~ You may obtain a copy of the License at | |
~ | |
~ http://www.apache.org/licenses/LICENSE-2.0 | |
~ | |
~ Unless required by applicable law or agreed to in writing, software |
humanswitchsupport
/ consentcookie-GTM-custom-html-tag.js
Last active
October 24, 2018 12:00
GTM ConsentCookie tag
This file contains 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
<script src="//cdn.humanswitch.services/cc/consentcookie/consentcookie-v1.min.js"></script> | |
<script> | |
(function(window) { | |
window.ConsentCookie.init({{ConsentCookie configuration}}); | |
// Fire ccConsent-<id> events on page load | |
var consents = ConsentCookie.get().consents; | |
for (var consentId in consents) { | |
if (consents.hasOwnProperty(consentId)) { | |
var consent = consents[consentId]; |
humanswitchsupport
/ consentcookie-GTM-configvariable-example.js
Created
April 19, 2018 12:51
ConsentCookie GTM configuration variable example
This file contains 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
function() { | |
return { | |
"apps": { | |
"consent": { | |
"cc": { | |
"initstate": "optin" | |
}, | |
"ga": { | |
"initstate": "optin" | |
} |
humanswitchsupport
/ consentcookie-config-variabele-structure.js
Last active
April 19, 2018 12:28
GTM ConsentCookie Configuration variabele structure
This file contains 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
function() { | |
return <ConsentCookie configuration object>; | |
} |
humanswitchsupport
/ consentcookie-ga-example.html
Created
March 22, 2018 15:40
Load Google Analytics based on the ConsentCookie preference of the user
This file contains 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
<script> | |
// Check if the user accepted the Google Analytics consent | |
if (ConsentCookie.get("ga").flag === 1) { | |
// If so, load the Google Analytics integration script, | |
// https://developers.google.com/analytics/devguides/collection/analyticsjs/ | |
// The script provided by Google Anayltics | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |