Best Consent Logic for SST & Data Tag?

Hi!

I would like to know what you think is the best Consent Logic for SST & Data Tag.

Situation:

  • I am about to configure Consent logic in my Server Container.
  • On server, I have a Event Data Variable (marketing consent → granted / denied)

Question

Stape Server Tags offer a consent Setting eg Send data in case marketing consent given
I would like to use and control this Consent Settings, as it is easier than duplicate all triggers or use trigger as exception.

Example Event Data:

{
  ad_storage: true,
  ad_user_data: true,
  ad_personalization: true,
  analytics_storage: true,
  functionality_storage: true,
  personalization_storage: true,
  security_storage: true
}

Therefore:

  1. Can I send this Data Object with GA4 aswell, to make use of the built in Consent Settings of the Stape Plugins? Or else, can I reconstruct the same consent object, the Data Tag would send?

  2. Is there an even better approach for implementing consent without making it as ugly and complicated as in the old days? (with custom trigger for each consent state) :innocent:

Thanks for your insights!

Server Tag by Stape

Hi @DigitalMasters

Data tag transfers the consent state from google consent mode: About consent mode - Google Ads Help

In order for this to work - you need your consent banner to support GCM, in this case if you activate this option - along with the event data the consent state at the moment the tag is running will also be transmitted.

In general it is recommended to use banners with GCM as it allows you to activate for GA4 and Google ADS consent modelling: About consent mode modeling - Google Ads Help

Hi Alex,

thank you for your answer, but I asked something completely different.
I am NOT talking about Consent Management on Client side, this is all set. Don’t worry about it.

Those are my questions:

I already found my answer by looking into the Code of your Server Tags:

The consent settings primarily revolve around the function isConsentGivenOrNotRequired(), which checks whether consent is provided or if it is not required. The key points for consent handling are:

  1. Storage Consent Check (adStorageConsent):
  • If adStorageConsent is not required (data.adStorageConsent !== 'required'), the function returns true, meaning no consent is required, and data processing can proceed.
  • If consent is required, it checks the eventData.consent_state object to verify if ad_storage consent has been granted (!!eventData.consent_state.ad_storage).
  1. Fallback Check for Google Consent Mode (x-ga-gcs):
  • The function also checks a specific string (x-ga-gcs), where the third character (index 2) represents the consent status for Google’s consent mode. If this character is ‘1’, consent is given; otherwise, it is not.
  1. Behavior Based on Consent:
  • If consent is not provided, the process terminates early, returning data.gtmOnSuccess() without further action.
  • If consent is provided or not required, the tag proceeds with data collection, cookie setting, and sending requests to the API.

Thus, the function ensures that data processing and tracking only occur when consent has been granted or is not necessary based on the configured settings.

Hi @DigitalMasters,

I can confirm that you have described everything correctly about checking the consent in tags, the object consent_state is used.

If you send in a GA4 hit with the same structure - everything will work on tags that support this.

GA4 Does not support Objects. How can I do it?

You can pass a custom object to GA4 by first doing JSON.stingify on the client and using a custom variable on the server to do JSON.parse

Thanks!

what kind of variable on Client? (custom javascript?)
and What kind on server? (cjs not available)

Yes, on a web container you can do this with a custom js variable. On the server you need to create your own custom variable that will take the required parameter (or look for the required key in event data) and do JSON.parse for it.

How does this work on Server GTM?

@DigitalMasters

1 Like