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

101
Views
How to properly control the google analytics cookie from javascript?

Currently I have set up the cookie prompt to override document.cookie set method, so that it stores non-required cookies and waits for user input (which cookies the user allows to use in the web page) to decide about other cookies.

Code looks something like this:

const originalSetter = document.__lookupSetter__('cookie');

function newSetter(cookie) {
    if (isRequired(cookie)) {
        originalSetter(cookie);
    } 
    else {
        //store the cookie and decide later.
    }
}
document.__defineSetter__('cookie', newSetter);

Since the google analytics cookie is not a required one (at least in my page), is this the correct approach or is there another way to do this?

about 4 years ago · Juan Pablo Isaza
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!