Cookie Law Info 2.0.0 has two custom JavaScript events:

  1. Cookie consent given
  2. The [delete_cookies] shortcode button has been pressed

These custom events mean you can extend Cookie Law Info for all kinds of things such as setting a global JavaScript variable to indicate you have consent, showing the visitor a custom message on receiving consent, updating a data layer or CRM system or even recording the IP address of those who have accepted if you wish to.

Difficulty level: intermediate To use these, add some JavaScript to your page like this:

[javascript]function cli_test_listener() {
    console.log("You have cookie consent");
}
function cli_test_listener_del() {
    alert("Cookie deleted");
}
document.addEventListener('cookielawinfo-consent', cli_test_listener, false);
document.addEventListener('cookielawinfo-delete-viewed', cli_test_listener_del, false);[/javascript]

Enjoy! I’d be interested to hear how you decided to use these custom events on your own website. Let me know in the comments below 🙂