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.
Last updated
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.
Last updated
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 consent-state events might be useful for this.
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.
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.
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.
To use Google Tag Manager, you must instead copy this custom code into a Google Tag. Google Tag Manager already has some predefined implementation, where you only need to setup the tag in Google Tag Manager, without any code. Google Tag Manager also supports custom code, 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 help center.
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 following these steps, please be sure that you have:
A Google Tag Manager account
Installed Openli's cookie-consent solution on your page
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.
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.
For example, this guide shows you how to setup Google Analytics tag with the appropriate trigger.
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.
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.