|
<script src='https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.js'></script> |
|
<script> |
|
var cookieconsent = initCookieConsent(); |
|
cookieconsent.run({ |
|
current_lang : 'en', |
|
page_scripts: true, |
|
|
|
autorun : true, |
|
delay : 0, |
|
autoclear_cookies : true, |
|
|
|
theme_css : 'https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.css', |
|
|
|
gui_options: { |
|
consent_modal : { |
|
layout : 'cloud', // box/cloud/bar |
|
position : 'bottom center', // bottom/top + left/right/center |
|
transition: 'slide' // zoom/slide |
|
}, |
|
settings_modal : { |
|
layout : 'box', // box/bar |
|
transition: 'slide', // zoom/slide |
|
} |
|
}, |
|
|
|
onAccept: function(cookies){ |
|
if(cookieconsent.allowedCategory('necessary')){ |
|
var dataLayer = window.dataLayer || []; |
|
dataLayer.push({ |
|
event:"CookieConsent", |
|
consentType:"necessary" |
|
}); |
|
} |
|
|
|
|
|
if(cookieconsent.allowedCategory('tracking')){ |
|
var dataLayer = window.dataLayer || []; |
|
dataLayer.push({ |
|
event:"CookieConsent", |
|
consentType:"tracking" |
|
}); |
|
} |
|
|
|
if(cookieconsent.allowedCategory('performance')){ |
|
var dataLayer = window.dataLayer || []; |
|
dataLayer.push({ |
|
event:"CookieConsent", |
|
consentType:"performance" |
|
}); |
|
} |
|
|
|
|
|
}, |
|
|
|
languages : { |
|
'en' : { |
|
consent_modal : { |
|
title : "Cookies information", |
|
description : 'By clicking on "Accept all cookies", you agree to storage cookies on your device, which helps with site navigation, data usage analysis and our marketing efforts.', |
|
primary_btn: { |
|
text: 'Accept All Cookies', |
|
role: 'accept_all' //'accept_selected' or 'accept_all' |
|
}, |
|
secondary_btn: { |
|
text : 'Cookies Prefences', |
|
role : 'settings' //'settings' or 'accept_necessary' |
|
} |
|
}, |
|
settings_modal : { |
|
title : 'Cookies settings', |
|
save_settings_btn : "Save preferences", |
|
accept_all_btn : "Accept All", |
|
close_btn_label: "Close", |
|
cookie_table_headers : [ |
|
{col1: "Cookie" }, |
|
{col2: "Description" }, |
|
|
|
|
|
], |
|
blocks : [ |
|
{ |
|
title : "We use Cookies", |
|
description: 'We use cookies for analysis of our visitor data, to improve our website, show personalized content and to give you a great website experience. By using this website, you consent to this use.', |
|
},{ |
|
title : "Functional Cookies", |
|
description: 'These cookies are necessary for the Website to work, so it is not possible to disable them. They are usually set up in response to an action you take on the Website yourself, such as security settings, logging in, and filling out forms. You can set your browser to block cookies or send notifications about them. Keep in mind that some pages will not work without these files. These cookies do not store any information that can be assigned to a specific person. These cookies may be set by us or by third party providers whose services we use on the website. These cookies do not store any information that can be assigned to a specific person.', |
|
toggle : { |
|
value : 'necessary', |
|
enabled : true, |
|
readonly: true |
|
}, |
|
cookie_table: [ |
|
{ |
|
col1: 'cc_cookie', |
|
col2: 'Your Cookies Preferences from this dialog.' |
|
} |
|
] |
|
},{ |
|
title : "Analytics Cookies", |
|
description: 'These cookies are used to improve the functioning of the Website. They allow us to recognize and track the number of visitors and track how visitors use the Website. They help us improve the way the Website works, for example, by allowing users to easily find what they are looking for. These cookies do not collect information that could identify you. Using these tools, we analyze and regularly improve the functionality of our Website. We can use the obtained statistics to improve user comfort and to make your visit to the Website more interesting for you as a user.', |
|
toggle : { |
|
value : 'performance', |
|
enabled : true, |
|
readonly: false |
|
}, |
|
cookie_table: [ |
|
{ |
|
col1: '_ga/_ga*, _gid', |
|
col2: 'Google Analytics - store and count pageviews.', |
|
}, |
|
{ |
|
col1: '_gcl_au', |
|
col2: 'Google Tag Manager - Conversion linker funcionality', |
|
} |
|
] |
|
},{ |
|
title : "Marketing cookies", |
|
description: 'They are used to monitor a user\'s website preferences for the purpose of targeting advertising, ie displaying marketing and advertising messages (even on third-party sites) that may be of interest to the website visitor, in accordance with these preferences. Marketing cookies use the tools of external companies. These marketing cookies will be used only with your consent.', |
|
toggle : { |
|
value : 'tracking', |
|
enabled : false, |
|
readonly: false |
|
}, |
|
cookie_table: [ |
|
{ |
|
col1: '_fbp', |
|
col2: 'Facebook Pixel - display advertisements when either on Facebook or on a digital platform powered by Facebook advertising, after visiting the website.', |
|
}, |
|
] |
|
} |
|
] |
|
} |
|
} |
|
} |
|
}); |
|
|
|
if(!cookieconsent.validCookie('cc_cookie')){ |
|
var dataLayer = window.dataLayer || []; |
|
dataLayer.push({ |
|
event:"CookieConsent", |
|
consentType:"empty" |
|
}); |
|
|
|
|
|
} |
|
</script> |
@vsamal Jsou 2 možnosti. Ta jednodušší je nespouštět GA na událost All Pages, ale udělat si vlastní událost, která se spouští při události CookieConsent a v pravidlech bude, že je consentType = performance (je potřeba si vytvořit proměnou, která si hodnotu přečte z DataLayeru).
Druhá možnost je použít Consent Mode v GTM, kdy se GA spouští vždy, ale reaguje na nastavený consent. K tomu je potřeba do kódu lišty doplnit volání gtag, pro nastavování consentu a pořešit pár dalších věcí.
Co se týká mazání cookies, tak si osobně myslím, že je to nadbytečná funkcionalita, ale lze toho dosáhnout tak, že se nastaví zmíněná autoclear_cookies a k tomu se připraví tabulka cookies, aby lišta věděla, jaká cookies má promáznout podle nového souhlasu.