Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
How can I use Javascript to validate that I have disabled or granted the correct consent?

I am setting my GA4 consent to denied, then updating it to granted if the user approves. I want to validate that the javascript behind my cookie consent banner is setting the correct consent settings in GA4. I'm not using GTM. I'm just calling the gtag() Javascript directly on each page.

Seeing in the documentation that there are update and set functions I opened the browser console and tried to get the consent config back out of gtag. Some things I tried:

gtag('get', 'consent');
gtag('config','get');

... and various combinations but these never return anything.

I then checked the Google documentation and there is indeed a get function but it doesn't seem to act on the consent command, following a different pattern of verbs.

Is there a way to validate from the console in a way whether I have set granted or denied to the permissions?

It would be very useful for automated functional UI testing (Selenium/WebDriver etc) too.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda