Feel free to customize it for your own needs.
- So far, it works for the scripts from Google Analytics, Pardot (Salesforce), and YouTube/Vimeo.
- Cookie providers that are not required can be commented out or deleted.
- Extendable for other cookies.
- YouTube/Vimeo can either be confirmed by the cookie banner or directly on the overlay of the videos (HTML structure has to be adjusted - see below).
- CSS for Consent Banner and for YouTube Video overlay.
- Cookie settings can be changed via checkboxes on the banner.
- Cookies in the banner settings are grouped as "Essential Cookies", "Marketing/Analysis", "YouTube" but can be changed easily.
- Multilanguage support by reading out the lang attribute.
- Replace IDs in CookieConsent.js:
googlesitetag: {
gt_id: 'UA-XXXXXXXXXX-X'
},
pardot: {
piAId: 'xxxxx',
piCId: 'xxxx'
},- The HTML structure has to be adapted for YouTube/Vimeo:
<div id="video_wrapper-id" class="video" data-yt_video_src="https://www.youtube-nocookie.com/embed/{VIDEO_ID}?controls=0">
<div class="video_container">
<iframe height="343" src="" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<div class="cc_video-overlay js-video-overlay">
<div class="cc_video-overlay_container">
<div class="cc_video-overlay_text">By loading the video, you accept YouTube's privacy policy.</div>
<button onclick="showVideo('video_wrapper-id')">load video</button>
</div>
</div>
</div>(Replace {VIDEO_ID} with YouTube video ID.)
- Clone repository via git.
- Run
npm install - Customize files
src/js/CookieConsent.jsandsrc/css/CookieConsent.css. - Run
gulp - Use the new generated lib-files
Change the CookieConsent.js file in src folder
const cookieconsent_cookie_fn = {
...
'{CUSTOM_COOKIE_NAME}': {
allow: {ENABLE_COOKIE_FUNCTION},
deny: {DISABLE_COOKIE_FUNCTION}
},
}
function {ENABLE_COOKIE_FUNCTION} () {
// custom code
}
function {DISABLE_COOKIE_FUNCTION} () {
// custom code
}- Add cookie to an existing option or define a new option
window.cookieconsent = {
...
options: {
option1: {
cookies: ['googlesitetag', 'pardot', {CUSTOM_COOKIE_NAME}],
...- Define a custom option
window.cookieconsent = {
...
options: {
{CUSTOM_OPTION}: {
cookies: [{CUSTOM_COOKIE_NAME}],
text_en `{CUSTOM_TEXT_EN_FOR_OPTION}`
text_de `{CUSTOM_TEXT_DE_FOR_OPTION}`
...Then run command gulp and use the new created scripts in lib folder
Remove the following line in all languages in src/js/CookieConsent.js and change the styles.
<button class="cc-banner_btn-deny" onclick='denyAll()'>Deny</button>Define your own CSS-Layout. Adapt file src/scss/CookieConsent.scss to your needs.
Please open an issue. Thank you.