Skip to content

Instantly share code, notes, and snippets.

View humanswitchsupport's full-sized avatar

humanswitchsupport

View GitHub Profile
@humanswitchsupport
humanswitchsupport / GTM ConsentCookie tag
Last active October 24, 2018 14:43
ConsentCookie GoogleTagManager based on consentcookie cookie settings
<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)
<!--
~ 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
<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
humanswitchsupport / consentcookie-GTM-configvariable-example.js
Created April 19, 2018 12:51
ConsentCookie GTM configuration variable example
function() {
return {
"apps": {
"consent": {
"cc": {
"initstate": "optin"
},
"ga": {
"initstate": "optin"
}
@humanswitchsupport
humanswitchsupport / consentcookie-config-variabele-structure.js
Last active April 19, 2018 12:28
GTM ConsentCookie Configuration variabele structure
function() {
return <ConsentCookie configuration object>;
}
@humanswitchsupport
humanswitchsupport / consentcookie-ga-example.html
Created March 22, 2018 15:40
Load Google Analytics based on the ConsentCookie preference of the user
<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)