Openli
IntroductionGetting StartedTechnical DocumentationGet help
  • Getting started
    • Introduction
    • Dictionary
    • FAQ
      • IAB TCF v2.0
  • Privacy hub
    • How to create your privacy profile
    • How can I get an Openli Privacy Badge?
    • Vendor owners
    • Why are custom properties on vendors super valuable?
    • Setting up custom properties
  • Tasks
  • Cookie Consent Management
    • Quickstart
    • Checklist: Cookies
    • Cookie widget
      • Create a cookie policy
      • Create a cookie widget
      • Install the widget
      • Manually add any cookies
      • Customise your widget
      • How to get color codes
      • Set the widget language
      • Use custom link/button instead of Cookie Shield
      • Add company name to cookie pop-up
    • Categorise your cookies
    • Adding information to cookies
    • Adding information to your cookie providers
    • Blocking Cookies with Openli
    • Cookie expiration dates and lifespan
      • Changing expiration on Google Analytics cookies
  • Policy and agreement management
    • Generate your privacy policy
    • Changing an old cookie policy to a new on autopilot
    • Embed your policies and legal agreements
      • Embedding agreements without displaying a widget
    • Install the Privacy Badge
  • General Openli guides
    • Setting up SSO (Single Sign-On)
      • SSO with Azure AD (Microsoft)
      • SSO with Google
      • SSO with Okta
      • How to log in with SSO
    • Add a website to your Openli account
    • Using projects to handle multiple languages
    • Collect consents without storing IP addresses or user-agents
  • Technical documentation
    • Widget
      • Collect cookie consent
        • Blocking cookies
        • Blocking embedded media
        • Cookie-widget options
        • Consent state API
    • API
      • Services
        • Personal data
        • Subprocessors
    • Cookies set by Openli
  • System Specific Integration Guides
    • Cloudflare
  • Legacy integrations
    • Google Consent Mode
    • Google Tag Manager
      • Block cookies with GTM
      • Install Openli with GTM
      • Prevent triggers from firing in GTM
    • HubSpot
    • Pardot
    • Shopify
      • Install cookie widget
      • Integrate consent with checkout
    • Square Online
    • Squarespace
    • Webflow
    • Wix
Powered by GitBook
On this page
  • Creating a variable
  • Using the variable with a trigger
  1. Legacy integrations
  2. Google Tag Manager

Prevent triggers from firing in GTM

How to prevent triggers from firing, if consent has not been given on certain or all cookie categories.

PreviousInstall Openli with GTMNextHubSpot

Last updated 8 months ago

This courtesy guide is no longer actively tested by Openli, although it might still work.

Our cookie-consent widget intentionally uses a highly-compatible, highly-generic approach to integration. In most cases, it will be possible for your developers to adapt this guide's steps to any changes that might have been made to the target platform, in combination with their own general documentation. Our might be useful for this.

We have developed an API, which returns the current cookie consent state. This API can be used in a GTM Custom JavaScript variable to decide whether or not a trigger should fire.

Creating a variable

First step is to create a new variable, and select variable type Custom Javascript.

In the created variable, paste following snippet:

function() { return legal.getCookieConsentState().analytics; }

For marketing triggers, simply replace the analytics property in the snippet with the marketing property.

After pasting the snippet, save the variable with a name of your choosing.

Using the variable with a trigger

Select your desired tag, and then add or edit a trigger. In your trigger, choose the option like Some <actions> under This trigger fires on.

In the conditional selection list that appears, choose your newly created Custom Variable (will be by the name you have given it).

The next selection box should be set to equals.

Lastly, write true in the last box.

Save the trigger, and publish.

Your selected triggers will now only fire when user has consented to chosen categories.

consent-state events
Custom JavaScript Variable example.