GTM isConsentGranted always return true

Viewed 19

I'm trying to update the consent state of the analytics_storage using the updateConsentState API and it's always returning true. Here is my tag code:

const log = require('logToConsole');

const updateConsentState = require('updateConsentState');
const setDefaultConsentState = require('setDefaultConsentState');
const isConsentGranted = require('isConsentGranted');


setDefaultConsentState({
  analytics_storage: 'denied',
  'wait_for_update': 500
});
updateConsentState({
  analytics_storage: 'denied'
});


log(isConsentGranted('analytics_storage'));

// Call data.gtmOnSuccess when the tag is finished.
data.gtmOnSuccess();

Any idea what I'm doing wrong?

1 Answers

I found some official documentation here

It stated:

The update is guaranteed to be processed in this container before any queued items in the data layer.

When I called the 'updateConsentState' method, the next tag that was triggered had the correct content state.

Related