Skip to content

Google Tag Manager

Google Tag Manager deployment

Sites that ship tags through GTM can run OptinStack alongside Google Consent Mode v2. Install the runtime before GTM, import the downloadable template when needed, and test defaults and updates before you publish.

Development hostname: Configure and test on an assigned development hostname or in the dashboard; the hostname’s tier controls every feature.

Production: A verified custom production hostname can use the account’s Free assignment, a paid plan, or Workspace coverage.

Sites that ship tags through Google Tag Manager can run OptinStack alongside Google Consent Mode v2. The OptinStack runtime owns early blocking and consent records. GTM remains the place you configure Google tags, Additional Consent Checks, and triggers.

Install the OptinStack runtime in the document head before the GTM container snippet so consent defaults and blocking can initialize first.

How the pieces fit together

  • OptinStack runtime (early head script): shows the consent banner, blocks inventoried scripts and iframes until allowed, and emits Consent Mode signals.
  • OptinStack GTM template (optional): maps visitor choices into Google Consent Mode v2 updates on Consent Initialization. All Pages.
  • Your GTM tags: use built-in consent checks (and Additional Consent Checks where needed) so tags wait for the right categories.
  • Direct (non-GTM) trackers: still controlled by the OptinStack runtime inventory, not by GTM alone.

Prerequisites

  • An OptinStack project with your hostname registered and the runtime install path chosen.
  • A GTM web container for the same site.
  • Permission to edit the container and to publish after testing in GTM Preview and Tag Assistant.
  • An active Free, Pro, Business, Enterprise, or Workspace hostname assignment. Development and custom hostnames use the same entitlement rules.

1. Install the OptinStack runtime first

Place the OptinStack snippet as early as possible in <head>, without async or defer, and before GTM and other marketing scripts. Use the install snippet from your project dashboard or the install docs.

Illustrative order only: use your real site ID and GTM container snippet from each product.
HTML
<!-- OptinStack: load before GTM and other tags -->
<script src="https://api.optinstack.com/v1/js/runtime/stable/optinstack.js" data-optinstack-site="YOUR_SITE_ID" id="optinstack-consent-sdk"
></script> <!-- Google Tag Manager (after OptinStack) -->
<script>(function(w,d,s,l,i){/* standard GTM bootstrap */})</script>

Full install details:docs.optinstack.com/install.

2. Add the OptinStack GTM template

The official OptinStack template is distributed as a downloadable .tpl file. It is not currently published in the Community Template Gallery.

  • In GTM, open Templates → Tag Templates → New.
  • Open the menu (⋮) → Import and select the OptinStack .tpl file.
  • Save the template, then create a tag that uses it.
  • Trigger: Consent Initialization: All Pages (must fire before tags that depend on Consent Mode).

Download:OptinStack GTM template (.tpl).

3. Configure Consent Mode v2 defaults

In GTM Admin → Container Settings → Consent Overview (or your Consent Mode defaults UI), define defaults that match your banner mode and regions. A common pattern is a global default row plus regional rows for EU/EEA and other jurisdictions you target.

  • Map OptinStack categories to Google storage types (for example analytics_storage, ad_storage, ad_user_data, ad_personalization, functionality_storage, personalization_storage).
  • Use denied defaults where prior consent is required; allow only after the visitor grants the matching OptinStack categories.
  • Consent Mode configuration does not decide which privacy laws apply to your site, legal review remains yours.

Category and signal mapping:docs.optinstack.com/consent-mode.

4. Review every GTM tag

Walk the container tag list. Google tags can use built-in consent checks. Other tags often need Additional Consent Checks so they wait for the right categories.

  • Analytics tags: require analytics (and related) consent as appropriate.
  • Ads / remarketing tags: require marketing / ad storage signals as appropriate.
  • Remove leftover CMP templates, custom HTML CMP loaders, and old consent event triggers to avoid double banners or conflicting signals.

5. Test before you publish

  • GTM Preview: confirm the OptinStack consent tag fires on Consent Initialization before other tags.
  • Google Tag Assistant: confirm Consent Mode defaults, then updates after Accept / Reject / Save preferences.
  • Browser DevTools: verify the OptinStack runtime loads before GTM and that blocked trackers stay blocked until allowed.
  • Optional: run an OptinStack scan after publish to catch hard-coded trackers that GTM cannot control.

6. Keep non-GTM trackers under runtime control

Pixels and embeds injected outside GTM are not fixed by Consent Mode alone. Keep them in your OptinStack tracker inventory so the runtime can block or release them with visitor choice.

Current limitations

  • The OptinStack GTM template is not in the Community Template Gallery, import the downloadable .tpl file.
  • Consent Mode settings are not a legal determination of which laws apply to your property.
  • Every hostname needs an active Free, paid, Enterprise, or Workspace assignment. Development and custom production hostnames follow the same tier rules.

Next steps

Deep dive:Consent Mode documentation.

Step-by-step community guide:Integrate OptinStack with Google Tag Manager.

Quick checklist

  1. 1. Install the OptinStack runtime before GTM.
  2. 2. When needed, import the official downloadable OptinStack template.
  3. 3. Fire it on Consent Initialization – All Pages.
  4. 4. Test default and update signals in Tag Assistant before publishing.

Keep in mind

  • The template is not currently published in the Community Template Gallery.
  • Consent Mode configuration does not decide which privacy laws apply to your site.