It looks like Google Analytics and the Adsense default CMP adhere to TCF v2.0 which is a standard for consent management.
According to this documentation if you set the variable window.gtag_enable_tcf_support
to true
, this is how you enable Google Analytics compatibility.
If I understand correctly, consent 'TC strings' should flow through from whatever Consent Management Platform (CMP) you are using. In the case of the default Adsense one, it's the one you enable in your account to display GDPR consent message.
Please correct me if I'm wrong.
The google analytics code, EG https://www.googletagmanager.com/gtag/js?id=UA-1234567 shows that it determines whether each 'purpose' is granded or not based on responses from the CMP:
Use of gtag_enable_tcf_support
in GA tag code:
Purposes from CMP (true if allowed, false if not):
However, this still sets the cookie. It looks like to explicitly prevent GA cookies from being set you have to set the following window variable:
window['ga-disable-UA-XXXXXX-Y'] = true;
Where UA-XXXXXX-Y
is replaced with your Google Analytics ID.