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.