Skip to content
Consent Management
Guides
Google Tag Manager

Consent Management: Configuring Google Tag Manager

10minAstralisConsent Management
This tutorial is using an older, more manual approach in configuring Google Tag Manager. In most cases the Consent Mode integration is recommended.

In this tutorial, we'll configure Astralis consent to ensure tags only fire with consent from a Tag Manager. In this example, we'll use Google Tag Manager, however, these steps are also applicable to similar tag managers such as Adobe Tag Manager and Tealium.

After reading this, you'll be familiar with how to configure tags to respect consent.

Prerequisites

For this tutorial you'll need:

Regulation information

In Spring 2025, a German court ruled that Google Tag Manager cannot be included on any page without consent. This ruling is available in German here (opens in a new tab).

When implementing Astralis and Google Tag Manager for use in Europe and Germany specifically, seek the advice of your legal counsel on the proper implementation. In response to their advice, you may wish to load the GTM javascript only after consent is obtained from Astralis. To accomplish this, ensure that Astralis is loaded and initialized before Google Tag Manager. You can read more about this in the Fides.js documentation here.

Once Astralis is initialized, you should defer any loading of GTM javascript until after consent is obtained. The specific consent you wish to use to load GTM is a choice you and your legal counsel will need to make. Once you have obtained the agreed upon consent, you can check for it using the Astralis interface and load GTM based on the user's consent.

Create a GTM Variable

  1. Navigate to Variables → New to create a new GTM Variable.
  2. From the Choose variable type menu, select Data Layer Variable as the type:
Create Data Layer Variable
  1. Set the Data Layer Variable Name to the corresponding cookie key of the privacy notice you configured. In this example, we use Fides.consent.data_sales_and_sharing. Read about creating cookie keys as part of privacy notices here.
  2. Give the variable a suitable, identifiable name, such as Fides.DataSalesAndSharing. In certain cases, you may want to set a default value. For example, in opt-out consent, you would set the default value to true. See the example below:
Name the Data Layer Variable

Repeat this step to create a GTM variable for each of the cookie keys assigned to your privacy notices. You can define as many as you require but it's common to have variables for data_sales_and_sharing, analytics, marketing, functional and so on.

Configure a Trigger

Many third-party tools rely on you to correctly configure their tags to fire depending on user consent. A single consent trigger tag ensures that a third-party tag only fires when a user’s consent is appropriately set.

  1. Navigate to Triggers → New to create a new Trigger.
  2. From the Choose a trigger type menu, select the appropriate trigger, this can be anything you choose but is typically Page View or Custom Event:
Select Trigger Type

Ensure you use the appropriate trigger type for your tag. If your primary firing trigger is Page View based, use the Page View exception trigger. If your primary firing trigger is Custom Event based, use the Custom Event exception trigger.

  1. Give the trigger a suitable, identifiable name, such as Fides.DataSalesAndSharing.OptOut
  2. Set “This trigger fires on” to Some Page Views.
  3. In the “Fire this trigger when…” option, set the following:
    • The event field to match your user-defined variable earlier (e.g. Fides.DataSalesAndSharing)
    • The evaluation to equals
    • The value to false
Trigger Configuration

To suppress tags from firing where the user hasn't given consent, you can add your newly created trigger using the following steps:

  1. Navigate to Tags and select the Tag you would like to add a consent trigger to.
  2. Under Triggering you can add, remove or combine triggers. In this case, you are adding an exception that will suppress firing where you do not have consent. Select Add Exception to add your newly created trigger.
  3. Select the consent trigger created earlier (e.g. Fides.DataSales.Consent), which will add it as an exception to your tag:
Select Exception Tag

You should now see your trigger listed in your tag as an Exception. When configured as outlined in this tutorial, this tag will no longer fire if a user has opted out of Data Sales.

GTM Exception Tag

Repeat this step for any other tag you would like to apply consent to for any privacy notices you have configured for your organization in Astralis.

Configure Limited Data Use for Meta (Facebook)

Meta's implementation of data sales is unique to their platform, and requires specific configuration in Google Tag Manager.

To implement the Limited Data Use flag, the following modifications to your pixel are required:

GTM Exception Tag
  1. Add the line below before the Facebook pixel is initialized fbq('init', '{{YOUR_FACEBOOK_PIXEL_ID}}');
Facebook Pixel Updates
{{Fides.DataSalesAndSharing}} ? fbq('dataProcessingOptions', []) : fbq('dataProcessingOptions', ['LDU'], 0, 0);
Note about <noscript> tags

If your Meta pixel is using the <noscript></noscript> for non-javascript browsers, remove this from your pixel. Consent management solutions, like Astralis, rely on JavaScript; this pixel would risk firing, causing noncompliance.

Save your changes. Limited Data Use is now set when the pixel loads.

Update the Meta Pixel when consent changes

The steps above control the pixel when it first loads. They don't run again if the user changes their consent later. On a single page app, the page doesn't reload, so a pixel that loaded after an opt in keeps running after the user opts out. Astralis deletes the _fbp cookie on opt out, but the running pixel keeps sending events to Meta. Unless Continuous cookie deletion is on, it can also set _fbp again. A trigger that only controls when the pixel tag loads isn't enough to handle this.

To update the pixel when consent changes, add a tag that passes the user's choice to Meta's own consent controls every time Astralis updates consent. Fides.gtm() pushes a FidesUpdated event to the data layer whenever the user's consent changes, which you can use as a trigger.

  1. Navigate to Triggers → New, and select Custom Event as the trigger type.
  2. Set the Event name to FidesUpdated, set the trigger to fire on All Custom Events, and give it a name such as Fides.Updated.
  3. Navigate to Tags → New, and select Custom HTML as the tag type.
  4. Add the following code. Replace {{Fides.DataSalesAndSharing}} with the variable you created for the privacy notice that covers the Meta Pixel.
Meta Pixel consent update
<script>
  (function () {
    if (!window.fbq) return;
    var ok = {{Fides.DataSalesAndSharing}} === true;
    var geo = window.Fides && window.Fides.geolocation;
    if (geo && geo.country === "US") {
      window.fbq("dataProcessingOptions", ok ? [] : ["LDU"], 0, 0);
    } else {
      window.fbq("consent", ok ? "grant" : "revoke");
    }
  })();
</script>
  1. Under Advanced Settings → Tag firing options, select Unlimited so the tag fires on every consent change.
  2. Under Triggering, select the Fides.Updated trigger you created.
  3. Save and publish your container.

Outside the US, revoke stops the pixel completely and grant turns it back on. In the US, the tag sends Meta's Limited Data Use signal instead, which lets the pixel keep running while Meta limits how it uses the data. If you want the pixel fully off for US users who opt out as well, use revoke everywhere.

Don't create fbq yourself

If the pixel hasn't loaded, the tag does nothing. Don't define window.fbq in this tag to queue the call. Many pixel loaders skip loading Meta's script if window.fbq already exists, so the pixel would never load after a later opt in.

For more detail, including the Conversions API and how to test your setup, see Meta Pixel in the Fides.js installation guide.