Your country
Your status
Cookies consent interaction

How to control precisely the way your users are accepting the cookies ? How to know that the user has accepted the cookie, and how to synchronize it with a third-party script to be able to do even more ? This is possible using Cookies CK. When the user is clicking in the Cookies CK interface, it triggers a javascript event that you can use to connect to any other script.

How to intercept the event

When the user clicks to accept or refuse, it triggers an event that is managed by Cookies CK to allow the cookie or not in the browser. But sometimes you may need to get this information and use it to manage something else, like storing some information, or triggering another script from a third party.

If you want to listen the Cookies CK events, you can add this script in your page :

document.addEventListener("cookieckstate", function(e) {
    console.log(e.detail.name); // this is the name of the cookie
    console.log(e.detail.state); // this is the state of the user acceptance : 0 or 1
});

 

You can use the e.detail.name variable to check that you are listening the correct cookie, and use e.detail.state to check if the user has accepted or rejected the cookie.

Note that you can also have all as name for the Accept all button is clicked. In this case you can also get the individual name of each cookie, both are working.

 

Example of use

Go in the plugin system Cookies CK and add a Cookie in a platform named My test Platform

overview cookies edition

Then you can add this script in your page to intercept the user action specifically on this cookie name (in fact it's the platform name) :

document.addEventListener("cookieckstate", function(e) {
if (e.detail.name == 'My test Platform') {
console.log(e.detail.state);
// add your action here
}
});

Here you are checking the name of the cookie, it it matches the name of the platform given in the plugin interface, then you can use the state value to do what you want.

Have a nice coding !

Fast and powerful creation, customizable and responsive.

Read More

Favorites extensions

logo maximenuck 110 logo pagebuilderck 110 logo slideshowck 110template creator ck large 449

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Save