Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
How do cookie consent pop-ups work internally?

My project is linked with Google Analytics. Now I would like to create a cookie consent pop-up on my website to comply with EU regulations.

Now I see in the EU regulations that the user can select "allow" or "deny". And then you can anonymize Google Analytics. But how does this work internally in my code?

I don't really know how this all works in code, does anyone have examples?

On the internet you will find a lot about how to create the pop-up, but they never go further on how to code everything internally.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Cookies are files at are stored on your computer that the website can access, 3rd party cookies are cookies that other websites can access too. The most basic way of creating a cookie is by using the browsers local storage. Your allow/deny system can be as simple as a true/false value stored globally, use an if statement to check if cookies are allowed or not every time you get or store a value from local storage.

Here are some examples.

// This will store a value/cookie with the id "myKey" and the value "myValue"
Window.localStorage.setItem("myKey", "myValue");

// You can get the value/cookie you stored earlier by using the values ID, in this case it should return "myValue"
Window.localStorage.getItem("myKey");

// To delete a value/cookie do this
Window.localStorage.remove("myKey");

// this is your logic to check if cookies are allowed
let AreCookiesAllowed = true;

if (AreCookiesAllowed === true)
{
    // Do things with cookies
    Window.localStorage.setItem("theme", "dark");
}

Reference material can be found here.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!