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
  • Blocking cookies
  • What cookies do I use?
  • How do I set cookies using Google Tag Manager?
  • Before you start:
  • Step 1: Create triggers to set cookies
  • Step 2: Configure your tags
  • Example - Google Analytics
  • Done!
  1. Legacy integrations
  2. Google Tag Manager

Block cookies with GTM

Openli supports Google Tag Manager, which is an easy way to integrate your cookie consents. This guide shows you how to block cookies with Google Tag Manager.

PreviousGoogle Tag ManagerNextInstall Openli with GTM

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.

Blocking cookies

When using Openli with Google Tag Manager, you can easily block out external cookies when users have not given consent and activate the cookies again when the user has given consent. If you do not block cookies, based on your users consent, your solution is not compliant.

This guide will show you how to get started blocking your cookies.

What cookies do I use?

Good question! It can be very difficult to get an overview over, which cookies you use on your site. Openli automatically scan your site, and tells you what cookies you use. To see the cookies, that Openli has found on your site navigate to 'Cookies' from the side menu in the dashboard.

How do I set cookies using Google Tag Manager?

There are different ways to set cookies on your site. If you use a website builder, you might have installed plugins, which can set cookies. You might also have added custom code often by copy-and-pasting a <script>-code block into your source code.

Once you cookies and scripts are set up in Google Tag Manager, you must remove the </script> from the source code of your website, and only keep the Google Tag manager code.

Before you start:

Before following these steps, please be sure that you have:

Step 1: Create triggers to set cookies

As mentioned previously, you must have consent for your users before you can set your cookies. Openli will handle all of this for you, if you integrate with Google Tag Manager. In Google Tag Manager, you need to create triggers for when to set which cookies.

First you must create a custom trigger in Google Tag Manager. Triggers define how and when to run a certain script/tag - cookies. Click on "Triggers" in the side panel and click on "New".

You need to assign triggers to both your analytics and marketing tags. There is no need to add any triggers for when analytics or marketing consent is rejected, because our widget handles this internally. We only trigger your tags when the user has consented to a given category.

Click on editing pen icon and select Custom Event as trigger type from the side panel menu.

Hereafter, you're asked to provide an event for your trigger. With Openli you have two event names:

Event name

Description

legalmonster.cookie.analytics.accepted

This event is fired when a user gives consent to analytical cookies, and on every page-load when the user has already given consent to analytical cookies.

legalmonster.cookie.marketing.accepted

This event is fired when a user gives consent to marketing cookies, and on every page-load when the user has already given consent to marketing cookies.

Save your trigger. Remember, you must create a trigger for marketing cookies and another trigger for analytics cookies.

For your marketing trigger, you must use the legalmonster.cookie.marketing.accepted event name and for analytics you must use the legalmonster.cookie.analytics.accepted event name.

Step 2: Configure your tags

You now need to edit your tags, so they are triggered by your newly created trigger. Go through each of your tags. Once you've selected a tag, you must associate it with the appropriate trigger, i.e. analytics trigger for analytical cookies and marketing trigger for marketing cookies.

Lastly, in the bottom of the Tag Configuration window, you'll see a checkbox for "Enable overriding settings in this tag", which you must check.

Example - Google Analytics

From the trigger type overview select "Google Analytics - Universal" and from track type select "Event".

In the bottom of the Tag Configuration window, you'll see a checkbox for "Enable overriding settings in this tag", which you must check. Fill out the "Tracking Id" text field with your Google Analytics tracking Id.

Done!

Congratulations on completing your first step towards collecting compliant cookie consent. Pat your self on the back and know that our privacy mascot Li is proud of you.

To use Google Tag Manager, you must instead copy this custom code into a Google Tag. Google Tag Manager already has some, where you only need to setup the tag in Google Tag Manager, without any code. Google Tag Manager also supports , if you do not find your scripts or script provider in the predefined list. You can read more about what tags are, and how to use them with Google Tag Manager in Google's own .

A account

on your page

For example, this guide shows you how to setup tag with the appropriate trigger.

predefined implementation
custom code
help center
Google Tag Manager
Installed Google Tag Manager on your site
Installed Openli's cookie-consent solution
Google Analytics
In this example, the site uses cookies from Hotjar, Google Analytics, Hubspot, Twitter e.g.
A trigger for the marketing cookies
Editing the tag for HubSpot and assigning it the trigger "Accepted analytical cookies"
Available tags if you created the Openli triggers as described in step 1
consent-state events