← Back to Installation Guides
Installation Guide

Install SiteTrust Consent via Google Tag Manager

Use two GTM tags with the Consent Initialization trigger to load SiteTrust Consent before GA4, Google Ads, and any other tag fires.

Before you start

If your site loads Google Tag Manager in the head, use this guide. If you prefer to add a script directly to your site head without GTM, see the standard installation guide.

The key requirement: the Consent Mode v2 default must fire before any Google tag loads. GTM's Consent Initialization trigger makes this possible.

Step 1

Create the Consent Initialization tag

In GTM, create a new tag. Tag type: Custom HTML. Name it SiteTrust — Consent Default.

Paste this code:

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('consent', 'default', {
    ad_storage: 'denied',
    analytics_storage: 'denied',
    ad_user_data: 'denied',
    ad_personalization: 'denied',
    wait_for_update: 500
  });
</script>

Trigger: Consent Initialization — All Pages.

This tag sets all four Consent Mode v2 signals to denied before any other tag runs.

Step 2

Create the SiteTrust Consent Widget tag

Create a second tag. Tag type: Custom HTML. Name it SiteTrust — Consent Widget.

Paste this code, replacing YOUR_CONFIGURATION_ID with your actual configuration ID from the SiteTrust dashboard:

<script src="https://www.sitetrust.com/consent-widget.js"
  data-configuration-id="YOUR_CONFIGURATION_ID">
</script>

Trigger: Consent Initialization — All Pages.

Tag sequencing: set this tag to fire after SiteTrust — Consent Default.

Step 3

Verify the order

In GTM, open the SiteTrust — Consent Widget tag. Under Advanced Settings, find Tag Sequencing and set it to fire after SiteTrust — Consent Default. This guarantees the default fires first.

Step 4

Publish and test

Publish your GTM container. Then verify the installation:

  • Open your site in a browser
  • Open DevTools (F12) and go to Console
  • Paste this and reload the page:
window.dataLayer = window.dataLayer || [];
var _push = window.dataLayer.push;
window.dataLayer.push = function() {
  var args = arguments[0];
  if (args && args[0] === 'consent') console.log('[Consent Mode]', args[1], args[2]);
  return _push.apply(this, arguments);
}

You should see:

[Consent Mode] default { ad_storage: denied, analytics_storage: denied, ad_user_data: denied, ad_personalization: denied, wait_for_update: 500 }

Click Accept All — you should see:

[Consent Mode] update { ad_storage: granted, analytics_storage: granted, ad_user_data: granted, ad_personalization: granted }

Important notes

  • Do not load consent-widget.js in the site head AND in GTM at the same time. Use one method only.
  • Your Configuration ID is available in the SiteTrust dashboard under Banner Setup, in the Installation card above the Header snippet.
  • GA4 and Google Ads tags should use the Built-in Consent Check in GTM so they wait for the consent update before firing.

Need help?

Email wecare@sitetrust.com with your site URL and platform. One business day response.