Server GTM does not have a built-in consent management system. Most of the SGTM templates require ad_storage consent. This standard provides a way to manage consent in the SGTM templates.
- Each template must have a
consentSettingsGroup
parameter. consentGroup
must contain aadStorageConsent
parameter.adStorageConsent
must contain one of these valuesoptional
,required
.- By default,
adStorageConsent
must beoptional
. - If
adStorageConsent
isrequired
, the template must check if the consent is given and send data only if the consent is given. - If
adStorageConsent
isoptional
, the template must send data always. - The template must check if the consent is given by the
consent_state
orx-ga-gcs
property.
const eventData = getAllEventData();
if (!isConsentGivenOrNotRequired()) {
return data.gtmOnSuccess();
}
function isConsentGivenOrNotRequired() {
if (data.adStorageConsent !== 'required') return true;
if (eventData.consent_state) return !!eventData.consent_state.ad_storage;
const xGaGcs = eventData['x-ga-gcs'] || ''; // x-ga-gcs is a string like "G110"
return xGaGcs[2] === '1';
}
{
"type": "GROUP",
"name": "consentSettingsGroup",
"displayName": "Consent Settings",
"groupStyle": "ZIPPY_CLOSED",
"subParams": [
{
"type": "RADIO",
"name": "adStorageConsent",
"displayName": "",
"radioItems": [
{
"value": "optional",
"displayValue": "Send data always"
},
{
"value": "required",
"displayValue": "Send data in case marketing consent given"
}
],
"simpleValueType": true,
"defaultValue": "optional"
}
]
}