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.
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.
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:
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:
A trigger for the 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.acceptedevent name and for analytics you must use the
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.
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
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.
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.