Coder Social home page Coder Social logo

orestbida / cookieconsent Goto Github PK

View Code? Open in Web Editor NEW
3.8K 49.0 399.0 35.92 MB

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js

Home Page: https://playground.cookieconsent.orestbida.com/

License: MIT License

CSS 0.83% JavaScript 69.30% SCSS 21.86% Astro 8.00%
cookie-consent gdpr cookie-policy cookieconsent javascript-plugin cookie-settings

cookieconsent's Introduction

CookieConsent v3

License: MIT Latest version CircleCI

A lightweight & gdpr compliant cookie consent plugin written in plain javascript.

CookieConsent v3 cover

Demo

Check out the playground.

There are also a few examples available on Stackblitz.

Documentation

Docs. available at cookieconsent.orestbida.com.

Contributing

Please read the contribution guide.

Thanks to all the people who already contributed!



A special thanks goes Till Sanders for creating and maintaining the npm package!

License

Distributed under the MIT License. See LICENSE for more information.

cookieconsent's People

Contributors

alimony avatar ben-larson avatar clgleroux avatar diewy avatar elliot67 avatar eremaijala avatar frusznyak avatar gijss avatar idrinth avatar kamilpesek avatar lneugebauer avatar moritzlost avatar ndresx avatar nexis81 avatar ondram avatar orestbida avatar peaemaye avatar rodriciru avatar softcreatr avatar techfg avatar tillsanders avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cookieconsent's Issues

On modal visible action

How can I do some action when user open modal with preferences?
I'm using fullPage.js so when I scroll in modal it scrolls my page on background instead modal. I would like to disable fullPage.js scrolling when modal is opened and enable it back when modal disappear.

How to Load Scripts with HTML Attributes

I am using the loadScript function to run a script whose script start tag has attributes.

For example, if I run a script that would normally be run like so:

<script src="https://example.com/example.js"></script>

Using loadScript I would use:

cc.loadScript("https://example.com/example.js");

But, how would I use loadScript with something like this:

<script src="https://example.com/example.js" id="someId" class="someClass" data-code="someData"></script>

Is it possible to pass those script start tag attributes to loadScript?

Add documentation on how to use cookieconsent in React/Next.js and React Native Web

This is an excellent cookie management script. Thank you so much for writing and maintaining it!

Please add documentation on how to use cookieconsent from within React based projects.

Currently I am using cookieconsent successfully on a Next.js website and in a React Native Web App (Expo Bare Workflow) under the same domain name. I am not sure if the way I am integrating cookieconsent is the correct or best way, but I was able to get everything working with Google Analytics and cookieconsent.

GDPR compliant

Add the option to make it GDPR compliant for those who wish to, by writing their own custom cookie consent policy.

  • custom cookie consent policy title and description
  • add custom blocks describing types of cookies and what are they used for
  • add for each block (describing a specific type of cookie) opt-in/out option
  • add custom block to make it possible for users to contact you for further info. about your policy

Toggle should be colored (red | green)

First: I love "cookieconsent". Great work. Thank you!

It would be nice if you could add something, that the user knows, what the state of the switch is.

Mabe but in front or behind the switch "allowed" | "denied", or make it colorfull
image

BTW: On / Off is not the best wording, I only insert it because it was short enough ;)

Suggestion: add a callback for Rejected cookies

I couldn't find any callback to handle people who press "Reject cookies". Solved it temporarily by attaching the click event to the rejected button created in the DOM.

$(document).on('click', '#c-s-bn', function()
{
	document.cookie = "cc_cookie=;expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=[put-your-domain-here]";
	window.location.href = 'https://google.com';		
});

Clarify cookieconsent's initialization methods

After navigating on the site, cookie settings won't open anymore.

See on my website at the bottom of the site: opkh.fi

Here's the code
<button type="button" class="btn btn-outline-primary" aria-label="View cookie settings" data-cc="c-settings">Muokkaa evästeasetuksia</button>

Analytics Cookies Section not responsive

Hello,

First of all thank you for the plugin!! It's really helpful and lightweight!
Secondly I am facing the problem/bug below. The Analytics Cookies Section in the Change Preferences section isn't responsive (regarding the Privacy Links).

Analytics_Section

Thank you very much!

Installation of the Cookie Consent

I've got an error when installing this for the first time.

image

Here is my code :

`
<script src="https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.js"></script>

<script>
	// obtain cookieconsent plugin
	var cc = initCookieConsent();

	// run plugin with config object
	cc.run({
		autorun : true, 							
		delay : 0,
		current_lang : 'en',
		theme_css : "../src/cookieconsent.css",		
		autoclear_cookies : true,	
		cookie_expiration : 365,
		
		gui_options : {
			consent_modal : {
				layout : 'cloud',
				position : 'bottom',
				transition : 'slide'
			},
			settings_modal : {
				layout : 'box',
				transition : 'slide'
			}
		},
		
		onAccept: function(cookies){				
			if(cc.allowedCategory('analytics_cookies')){
				cc.loadScript('https://www.google-analytics.com/analytics.js', function(){		
					ga('create', 'UA-XXXXXXXX-Y', 'auto');  //replace UA-XXXXXXXX-Y with your tracking code
					ga('send', 'pageview');
				});
			}
		},
		
		languages : {
			en : {	
				consent_modal : {
					title :  "I use cookies",
					description :  'Hi, this website uses essential cookies to ensure its proper operation and tracking cookies to understand how you interact with it. The latter will be set only upon approval. <a aria-label="Cookie policy" class="cc-link" href="#">Read more</a>',
					primary_btn: {
						text: 'Accept',
						role: 'accept_all'				//'accept_selected' or 'accept_all'
					},
					secondary_btn: {
						text : 'Settings',
						role : 'settings'				//'settings' or 'accept_necessary'
					}
				},
				settings_modal : {
					title : 'Cookie preferences',
					save_settings_btn : "Save settings",
					accept_all_btn : "Accept all",
					cookie_table_headers : [
						{col1: "Name" }, 
						{col2: "Domain" }, 
						{col3: "Expiration" }, 
						{col4: "Description" }, 
						{col5: "Type" }
					],
					blocks : [
						{
							title : "Cookie usage",
							description: 'I use cookies to ensure the basic functionalities of the website and to enhance your online experience. You can choose for each category to opt-in/out whenever you want.'
						},{
							title : "Strictly necessary cookies",
							description: 'These cookies are essential for the proper functioning of my website. Without these cookies, the website would not work properly.',
							toggle : {
								value : 'necessary_cookies',
								enabled : true,
								readonly: true
							}
						},{
							title : "Analytics cookies",
							description: 'These cookies ollect information about how you use the website, which pages you visited and which links you clicked on. All of the data is anonymized and cannot be used to identify you.',
							toggle : {
								value : 'analytics_cookies',
								enabled : false,
								readonly: false
							},
							cookie_table: [
								{
									col1: '_ga',
									col2: 'google.com',
									col3: '2 years',
									col4: 'description ...' ,
									col5: 'Permanent cookie'
								},
								{
									col1: '_gat',
									col2: 'google.com',
									col3: '1 minute',
									col4: 'description ...' ,
									col5: 'Permanent cookie'
								},
								{
									col1: '_gid',
									col2: 'google.com',
									col3: '1 day',
									col4: 'description ...' ,
									col5: 'Permanent cookie'
								}
							]
						},{
							title : "More information",
							description: 'For any queries in relation to my policy on cookies and your choices, please <a class="cc-link" href="#yourwebsite">contact me</a>.',
						}
					]
				}
			}
		}
	});

`

Extend API methods (e.g. cookieconsent.accept_necessary)

This is a great script! 🔥

One feature I am missing, is the ability to manually change the user's cookie consent for example with a cookieconsent.accept_necessary method.

Other methods could be:
cookieconsent.accept("statistics")
cookieconsent.accept(["statistics", "marketing"])
cookieconsent.accept_all()

In my specific usecase, I would like to theme the consent banner and add a third "Accept necessary" option, next to the "Accept all" and "Settings" Options. I would like all three options and add the "Accept necessary" option as a Javascript href in the top description. Is there currently a way to do that without changing the "Settings" button type to accept_necessary?

Do you plan on extending the exposed API functions?

Known issue GTM with GA4

Hello again :-),

we have got many online shops and one shop has got a Google Tag Manager with Google Analytics 4 implementation.

After I denied the Cookies:

CookieConsent [AUTOCLEAR]: deleting cookie: '_ga_YZ791V8SYH' path: '/' domain: (2) ["xxx-xxx", ".xxx-xxx"] cookieconsent.js:900 CookieConsent [AUTOCLEAR]: deleting cookie: '_ga' path: '/' domain: (2) ["xxx-xxx", ". xxx-xxx"] cookieconsent.js:900 CookieConsent [SET_COOKIE]: cookie cc_cookie='{"level": ["necessary"]}' was set!

Now I reload the page and 1 of 2 Google Cookies are still available: _ga_YZ791V8SYH

This is only by Google Tag Manager with Google Analytics 4.

Thanks

Feature Request: Allow all cookies button

Hey!

I love your pure JS CSS solution to show a cookie consent banner.
However to bring this to it's full advantage I was wondering how I could add more buttons to the modal that is shown.

I would like to treat the "I understand" button as an Allow all cookies button, however I would also like to add other buttons which allow for selection such as "allow necessary cookies only"

Reject All option?

Hello,
I'm looking to implement this, but am legally required to have a "Dismiss All" button on the banner alongside "Accept All", though I can't see any config options for dismissing all at once - is there a way to do this?

Facebook Pixel Cookie

Hello, If I have denied all cookies, then all cookies are deleted! Works, but If I have changed next page only _fbp cookie is visible. I don't know why.

<!-- INLINE FB --> <script type="text/plain" data-cookiecategory="analytics"> !function (f, b, e, v, n, t, s) { if (f.fbq) return; n = f.fbq = function () { n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments) }; if (!f._fbq) f._fbq = n; n.push = n; n.loaded = !0; n.version = '2.0'; n.queue = []; t = b.createElement(e); t.async = !0; t.src = v; s = b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s) }(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '4711'); fbq('track', 'PageView'); console.log("loaded gtm.js"); </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=4711&ev=PageView&noscript=1"/></noscript>

Thanks!

Problem with Google Analytics

Hi,
I have enabled Google Analytics (tag manager) onAccept and I can track without problems page visualizations, but I'm unable to track anchors clicks like:

<a onClick="gtag([your event code])" href="">[your anchor]</a>

console return error "can't find variable gtag.
I have also try to enable scripts on page, without success.

Any solution?

Cookie value not standards compliant

This is an awkward issue, because the plugin obviously works, but the value of cc_cookie is not standards compliant.

The standards for cookies are kind of a mess, but from here:

A cookie-value can optionally be wrapped in double quotes and include any US-ASCII characters excluding control characters, Whitespace, double quotes, comma, semicolon, and backslash.

That means that to properly include JSON in a cookie value, it really ought to be escaped, which would be a breaking change.

Since it seems that this is already working in all supported browsers without escaping the value, maybe this isn't worth addressing. I came across this because I was considering (and eventually decided against) setting cc_cookie server side for users who were logged in and had indicated their preferences previously. My server-side cookie implementation was smart enough to know that some of the characters I was trying to set were not permitted.

One reasonably backward-compatible solution (if this is worth solving) would be to create a new major version of the package that writes a new format, identical to the old, but escaped, and also converts any cookies it encounters in the old format to the new. This would still require changes for anyone using the value of cc_cookie server side directly.

Exmaple + CDN files does not delete any cookie

Hi,

I copied your example and use it with the CDN files provided.

Am I missing something obvious in that configuration?????

 // obtain cookieconsent plugin
    var cc = initCookieConsent();

    // run plugin with config object
    cc.run({
        delay : 0,
        autorun : true, 	
        current_lang : 'en',
        force_consent : true,
        cookie_expiration : 365,
        autoclear_cookies : true,	
        theme_css : "https://cdn.jsdelivr.net/gh/orestbida/[email protected]/dist/cookieconsent.css",
        gui_options : {
            consent_modal : {
                layout : 'cloud',
                position : 'bottom',
                transition : 'slide'
            },
            settings_modal : {
                layout : 'box',
                transition : 'slide'
            }
        },
        
        onChange(cookies){
            alert("ONCHANGE")
        },

//*******************************************************************
onAccept: function(cookies){      
            console.log("I'M IN ONACCEPT")

            var categories_to_reject = []

            if (!cc.allowedCategory("analytics")){
                categories_to_reject.push("analytics")
            }
            
            console.log("cc.allowedCategory('analytics'):", cc.allowedCategory("analytics"))
            console.log('R', categories_to_reject)

            cc.accept('all',"analytics")
        },
//*******************************************************************
       languages : {
            en : {	
                consent_modal : {
                    title :  "TITLE",
                    description :  'DESCRIPTION',
                    primary_btn: {
                        text: 'ACCEPT ALL',  // cookies.level --> All categories
                        role: 'accept_all'				//'accept_selected' or 'accept_all'
                    },
                    secondary_btn: {
                        text : 'SETTINGS',
                        role : 'settings'				//'settings' or 'accept_necessary'
                    }
                },
                settings_modal : {
                    title : 'PREFERENCES',
                    save_settings_btn : "SAVE PREFERENCES",
                    accept_all_btn : "ACCEPT ALL", // cookies.level --> All categories
                    reject_all_btn : "REJECT ALL", // cookies.level --> All categories
                    cookie_table_headers : [
                        {col1: "NAME" }, 
                        {col2: "DOMAIN" }, 
                        {col3: "DESCRIPTION" }, 
                    ],
                    blocks : [

                        {   title : "NECESSARY",
                            description: 'NECESSARY_DESCRIPTION',
                            toggle : {
                                value : 'necessary',
                                enabled : true,
                                readonly: true
                            },
                            cookie_table: [
                                {   col1: 'cc_cookie',
                                    col2: 'localhost',
                                    col3: 'MY_DESCRIPTION',
                                },
                            ]
                        },
                        {   title : "ANALYTICS",
                            description: 'ANALYTICS_DESCRIPTION',
                            toggle : {
                                value : 'analytics',
                                enabled : false,
                                readonly: false
                            },
                            cookie_table: [
                                {   col1: '_ga',
                                    col2: 'localhost',
                                    col3: 'MY_DESCRIPTION',
                                },
                                {   col1: '_ga_86XY962EK4',
                                    col2: 'localhost',
                                    col3: 'MY_DESCRIPTION',
                                },
                            ]
                        },{
                            title : "MORE_INFO",
                            description: 'MORE_INFO_DESCRIPTION',
                        }
                    ]
                }
            }
        }
    });

Rows not visible in cookie table when too many cookies are listed

When adding multiple cookies in the same category (one per row), only the first few rows are correctly shown (I noticed that depends also from the number of columns).

Being that having one cookie per row is needed to activate the autoclear_cookies feature, it would be great not to have limits there. I think it's just a matter of some css properties in the table size because the rows are actually created, but somehow overflowing and not visible.

Thanks in advance!

(btw, great script, thanks a lot for it!)

EDIT:
for the moment I solved it with the following css:

#s-bl .c-bl.b-ex+.c-bl.b-ex {
margin-top: 0;
height: fit-content;
}

NPM package

Do you plan to create an NPM package?
Lots of advantages to manage version upgrade.
Thx

Cookies are not deleted when deactivating a group of cookies

Hello,
While wanting to try this plugin, I encountered a problem.

When i put in the options "auto clear cookies: true", the cookies are not deleted when you deactivate a group of cookies from the panel. And I understood why.

In my case, when cookies are first created, the domain stored in the browser's cookies section is the primary domain ".mydomain.com".

On the other hand, when I want to disabled them, the code tries to identify them by a different domain values, sometimes including the subdomain (ex: .www.mydomain.com).

And since it cannot find them in existing cookies, it does not delete them.

I'm pretty bad at JS, but I fixed my problem temporarily by adding the 4 lines below while waiting for a possible fix from you.

var _eraseCookies = function(cookies, custom_path) {
            var path = custom_path ? custom_path : '/';
            var expires = 'Expires=Thu, 01 Jan 1970 00:00:01 GMT;';

            for(var i=0; i<cookies.length; i++){
                document.cookie = cookies[i] +'=; Path='+ path +'; Domain=' + _config.cookie_domain + '; ' + expires;
                document.cookie = cookies[i] +'=; Path='+ path +'; Domain=.' + _config.cookie_domain + '; ' + expires;

                // START - PLUGIN OVERWRITE : add the main domain too (without subdomain)
                var domainSplit = _config.cookie_domain.split('.');
                var mainDomain = domainSplit[domainSplit.length - 2] + '.' + domainSplit[domainSplit.length - 1]
                document.cookie = cookies[i] +'=; Path='+ path +'; Domain=' + mainDomain + '; ' + expires;
                document.cookie = cookies[i] +'=; Path='+ path +'; Domain=.' + mainDomain + '; ' + expires;
                // END - PLUGIN OVERWRITE

                _log("CookieConsent [AUTOCLEAR]: deleting cookie: '" + cookies[i] + "' path: '" + path + "'");
            }
        }

Thank you for your help :)

Show consent modal every load until all cookies accepted

HI there!
Amazing script for first, ty for that ;)

For now i need my users to accept all cookies, even optionally ones, and for that i'm thinking, is possible to show the consent modal every time my users load on my page, if they do not accept ALL cookies?
I mean. I have 3 cookies on modal. One is mandatory (readonly) and the other two are optionally. So if they accept just the mandatory one, next time they load my page the consent screen doesnt show up, i need a differently behavior, i need this consent modal show everytime if they do not accept all other cookies, i see this a way to "force" then to accept all.
Is there a builtin option for that ?

Color management - idea

Hi,

Thank you for the script. You did great gob! 👍
Will be awesome add some color management to the section below, such as

auto_language : true,
buttons : #CCCC,
swich_on : #CCCC,
swich_off: #00000,
...
cookie_expiration : 365..

Thanks Again

Cookie pop up doesn't appear on home page.

Hello,

I don't know if it's a bug of something with my setup but when I visit my homepage the cookie pop up doesn't appear. It appears on all the other pages except the root directory of my site (I can provide the link if you want). Also if I want to add a cookie for AdSense is it possible to do it by using your addon?

EDIT1 : I'm also getting this error :
cookieconsent.js:27 Uncaught TypeError: Cannot read property 'appendChild' of null
at Da (cookieconsent.js:27)
at Object.n.run (cookieconsent.js:30)
at cookies.js:5

EDIT2 : Google Analytics seems to not getting data at all.

But I'm using your template file....

Consider splitting the script loader into a separate package or file

First, let me say that, so far, I love this package. I'm just starting to wire it up, but it seems that you've given this a lot of thought.

One thing I've run into (I hesitate to call it an issue) is that the script loader that is part of the package seems to be completely separate from the cookie consent functionality. There isn't any real reason for them to share an object. While loading a script is a common thing we want to do in response to consent being granted, there are a lot of ways to accomplish this. As far as I can tell, I can include cookieconsent either entirely or not at all in my code; I can't exclude the script loader, and while it isn't a huge feature, it is some unnecessary code.

I suggest that you consider splitting the script loader into another package (or even find another existing package that serves that purpose). You could still suggest loading that package, and use it in your examples, but I think that both packages would benefit from a separation of concerns.

Of course I may be missing some way they are integrated that makes this entire suggestion moot, in which case, please disregard this suggestion and carry on. :)

Google Analytics ^__utm

Hello, at first load I have got man ^__utm Cookies

  • __utmb
  • __utmt
  • __utma
  • __utmz
  • __utmc

How I can block?

{ col1: '^__utm', col2: '.shop.demo.de', col3: 'Google Analytics', is_regex: true },

Not working. Thanks!

EDIT: I See I have got 2 different cookie domains. (Main & Subdomain). Is this a problem?

Cookies do not delete if remove_cookie_tables enabled

Hi,

I've set autoclear_cookies and remove_cookie_tables to true but the cookies are not getting deleted when I'm pressing the "Reject All" button. If I set the remove_cookie_tables to false, press the "Reject All" button and then reload the page the cookies are getting deleted.

Can you please fix it?

Revision does not change in cc_cookie

Hello,

if I understand correctly, the revision is used to "signal" a change. Is it correct to say that if I change the "revision" parameter in the settings it will also change in the cookie?
Although I have changed the revision parameter, the box always appears and if I click on "accept all" the "revision" value in the "cc_cookie" remains the old one.

const cookieconsent = initCookieConsent();
cookieconsent.run({
    revision: 4,
    page_scripts: true,
    force_consent: true,
    cookie_expiration: 365,
    current_lang : 'it',
    theme_css : 'path',
    gui_options: {
        consent_modal : {
            layout : 'bar',               // box/cloud/bar
            position : 'bottom left',     // bottom/top + left/right/center
            transition: 'zoom'             // zoom/slide
        },
        settings_modal : {
            layout : 'box',                 // box/bar
            // position : 'left',           // left/right
            transition: 'slide'             // zoom/slide
        }
      },
      languages: {
        it : {
            consent_modal : {
                title:  "Noi usiamo i cookie",
                description:  'Noi usiamo i cookie e altre tecniche di tracciamento per migliorare la tua esperienza di navigazione nel nostro sito, per mostrarti contenuti personalizzati e annunci mirati, per analizzare il traffico sul nostro sito e per capire da dove arrivano i nostri visitatori.',
                primary_btn: {
                    text: 'Accetta',
                    role: 'accept_all'  //'accept_selected' or 'accept_all'
                },
                secondary_btn: {
                    text : 'Personalizza',
                    role : 'settings'   //'settings' or 'accept_necessary'
                }
            },
            settings_modal : {
                title : 'Centro Preferenze Cookie',
                save_settings_btn : "Salva Impostazioni",
                accept_all_btn : "Accetta",
                reject_all_btn : "Rifiuta", // optional, [v.2.5.0 +]
                close_btn_label: "Chiudi",   
                blocks : [
                    {
                        title : "Utilizzo dei Cookies",
                        description: 'I cookie sono dei piccolissimi file di testo che vengono memorizzati nel tuo computer quando visiti un sito web. Noi usiamo i cookie per una varietà di scopi e per migliorare la tua esperienza online nel nostro sito web. Tu puoi cambiare le tue impostazioni e rifiutare che alcuni tipi di cookie vengano memorizzati sul tuo computer mentre stai navigando nel nostro sito web. Puoi anche rimuovere qualsiasi cookie già memorizzato nel tuo computer, ma ricorda che cancellare i cookie può impedirti di utilizzare alcune parti del nostro sito.',
                    }, {
                        title : "Cookie strettamente necessari",
                        description: 'I cookie necessari contribuiscono a rendere fruibile il sito web abilitandone funzionalità di base quali la navigazione sulle pagine e l\'accesso alle aree protette del sito. Il sito web non è in grado di funzionare correttamente senza questi cookie.',
                        toggle : {
                            value : 'necessary',
                            enabled : true,
                            readonly: true
                        }
                    }, {
                        title : "Cookie di tracciamento e prestazione",
                        description: 'I cookie di tracciamento e prestazione aiutano i proprietari del sito web a capire come i visitatori interagiscono con i siti raccogliendo e trasmettendo informazioni in forma anonima.',
                        toggle : {
                            value : 'analytics',
                            enabled : true,
                            readonly: false
                        }
                    }, {
                        title : "Cookie di targeting e pubblicità",
                        description: 'I cookie di targeting e pubblicità vengono utilizzati per tracciare i visitatori sui siti web. La finalità è quella di presentare annunci pubblicitari che siano rilevanti e coinvolgenti per il singolo utente e quindi di maggior valore per editori e inserzionisti di terze parti.',
                        toggle : {
                            value : 'marketing',
                            enabled : true,
                            readonly: false
                        }
                    }
                ]
            }
        }
    },
    onAccept: function(cookie) {
        if (cookieconsent.allowedCategory('analytics')) {
            gtag('consent', 'update', {
                'ad_storage': 'granted',
                'analytics_storage':'granted'
            });
        }
    },
    onChange: function() {
        if (cookieconsent.allowedCategory('analytics')) {
            gtag('consent', 'update', {
                'ad_storage': 'granted',
                'analytics_storage':'granted'
            });
        }
    }
});

When you refresh the page and "accept all", the revision property in "cc_cookie" does not change. Then, updating the page again, the box appears again.

PS
Sorry for my English :)

after saving settings user cannot revoke them

congrats for a wonderful repo, thank you,
question, when user clicks in settings, and changes some settings and clicks on "save settings", the popup disappears and never reappears again. So how is the user supposed to revoke or change again those settings? there should be a way to do that,
thank you :)

The possibility to remove the console logs would be nice

It would be great to have the possibility to remove the console logs (for production sites, for example).
As a suggestion, it could be possible to create a DEBUG variable which could be set to true to show the console logs and false not to show them.

Enhancement: move ccb_cookies_table th to language file

All the table header field names of ccb_cookies_table are currently hardcoded on cookieconsent.js
As an enhacement request, plese move the TH to the language file.

Name | Domain | Description | Expiration | Type

Thanks a lot!

Delete cookies not working

Hello, if I disable locally (local webserver) tracking the cookies will be deleted after refresh. perfect! Now I have deployed all files to webspace, but the cookies are still available. I need help, please and sorry my bad English.

Google Analytics not working

Hi, I really like this project, but I can't get Google Analytics to work.

Once users grant permission, the site establishes a connection to the Google servers and places these cookies
image

I disabled tracking protection in my browser, but I still can't see any activity in Google Analytics real-time tab.
The Analytics Debugger Extension tells me this error
image

This is the relvant code I am using:
onAccept: function(cookies){ if(cc.allowedCategory('advanced_analytics')){ cc.loadScript('https://www.google-analytics.com/analytics.js', function(){ ga('create', 'G-81TL********', 'auto'); //replace UA-XXXXXXXX-Y with your tracking code ga('send', 'pageview'); }); } },
In my setup I used the Integration into OxygenBuilder from this post https://www.facebook.com/groups/1626639680763454/posts/4180752212018842
which makes the JavaScript and CSS load in a Code Block. The issue could be that it runs everything in the <body> instead of the usual <head>. I tried running the JavaScript in the <head>, but that broke the cookie consent form.

The site is inconveniently not public, but I would be really thankful if you could help me make Google Analytics work.

I am also wondering if it is possible to use Gtag instead of GAnalytics, it appears to be the recommended way of integration.

Custom cookie data / visitor identification

I absolutely love this little JS library and don't want to ask anything that could bloat its code unnecessarily.

Given that (at least) the Finnish authorities require that you can point the time when the visitor has accepted the cookies, we've implemented custom consent recording which saves these details to our database. Just to be on the safe side, as there is no precedent what this actually means.

Currently, the way how we've done this is a bit hacky, as it used separate cookie for giving each visitor their own UUID which is then used to "identify" visitors if needed. It works, though having everything in one cookie would be most ideal.

I do wish there would be a way to add custom data into the cookie OR having a native feature for generating visitor identifications. I will leave it up to you which way would be better, if any.

BTW we are packaging CookieConsent and IframeManager into WordPress plugin which will be published Open Source soon(ish) :)

A way to invalidate consent from the site

Thanks for all the great work.

It would be nice to make sure that site users are prompted to renew their consent if the site settings change.

E.g. if I have set up my site with
{"level": ["necessary","preferences"]}
and users have accepted that, and then I add "statistics".

Currently, I have to wait until the user's cookies time out (default six months) before I can start tracking "statistics" for users with old cc_cookies,

if the configuration is extended with an extra parameter:

Option Type Default Description
revision string null The current revision of the cookie consent, if updated existing users will be prompt to renew their consense

The the cookie is extended with the accepted revision
{"level": ["necessary","preferences"], "revision": "first"}

and if the current revision doesn't fit with users cookie revision, they need to approve again

Is it possible to add new section top of modal.

Hi, thanks for this job. It is very useful.

I want to ask that can we add new section next to the Coooki Setting at the top of the modal.

I want to add Cookie policy text in a new page. Is this possible or not.

Thanks for your great work.

Feature request: Expose a method to set the accepted revision

It would be useful to have a method to set the revision in the cookie, in the same way the .accept() method lets us set accepted levels.

The use case is as follows: I want to persist the consent choices (and revision) of the user on the server, so that if the user logs in from a different browser, their consent choices are remembered. I do this by retrieving their choices from the server and calling .accept() on their choices client side, if the cookie is not found.

But this means that if their choices remain the same, but I push out a new revision, if they log in from a new browser, I'll automatically "accept" them at the same level, under the new revision. If I could also set the revision, then the plugin will be able to detect that the revisions don't match, and show the consent modal with the revision dialog.

Adding locales

Hello,

I'd like to contribute by adding my language.
How to do so?

Best regards

cc_cookie not created if the domain name includes a port

Your plugin is awesome and the documentation is very helpful.

I've experienced a problem when using the plugin on my localhost which has a port (i.e. mydomain.com:8890): the cc_cookie is not created.

As a solution, I've replaced all occurences of 'location.host' and 'window.location.host' by 'location.hostname' and 'window.location.hostname'

How to change plugin position

I think it could be interesting for the developer to be able to change the modal position (top, top-right-left, bottom-right-left, etc..). Maybe it is already posible to do it, but i could not find it.

Thank you.

Regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.