I try to create GDRP notification with custom java script

Hello everyone, i try to create GDRP notification based on cookie file in bricks without plugin but using java script code .
I found this video: Cookie Consent Box using HTML CSS & JavaScript | Learn to Set Cookies to the User Browser - YouTube

For HTML and CSS I use template from bricks


I write class for container like in video (.wrapper) but don’t appere

script for notification

I try in script to change class wrapper to slug my template (406) and name (popup test) but don’t work, please help

I can shoot screen cast with my all steps

Hi Davido,
where is the script part?

Best regards,
timmse

I delete

const cookieBox = document.querySelector(".wrapper"),

acceptBtn = cookieBox.querySelector("button");

acceptBtn.onclick = ()=>{

  //setting cookie for 1 month, after one month it'll be expired automatically

  document.cookie = "CookieBy=CodingWebsty; max-age="+60*60*24*30;

  if(document.cookie){ //if cookie is set

    cookieBox.classList.add("hide"); //hide cookie box

  }else{ //if cookie not set then alert an error

    alert("Cookie can't be set! Please unblock this site from the cookie setting of your browser.");

  }

}

let checkCookie = document.cookie.indexOf("CookieBy=CodingWebsty"); //checking our cookie

//if cookie is set then hide the cookie box else show it

checkCookie != -1 ? cookieBox.classList.add("hide") : cookieBox.classList.remove("hide");

});

Hi Davido,

as already said here, this approach is not legally correct (at least not in Germany, where I live). I don’t know the legal situation in your home country, but again I would advise you to use a professional plugin for exactly this purpose, that gives you some legal security.

Many greetings
timmse

What is the difference between a plugin and a script? Doesn’t the plugin do the same thing?

Well, in the best case, the plugin reliably fulfills its purpose. And that definitely includes more than 10 lines of JavaScript when it comes to GDPR :smiley: