Google Tag Manager and Consent Mode v2

Optooki talks to Google tags directly: every visitor choice is passed on to them, with no setting in your container.

Consent Mode v2 is on by default (site Settings, “Google Consent Mode v2”). Before your Google tags, the script sends the default state, everything denied, then on each visitor choice the four signals Google expects:

SignalGranted when the visitor accepts
analytics_storageanalytics
ad_storageadvertising
ad_user_dataadvertising
ad_personalizationadvertising

Google Analytics 4 and Google Ads then adjust on their own: without consent, they write no cookie.

Optooki script and GTM container

The recommended way: the Optooki line first in the <head>, then the Google Tag Manager container.

<script src="https://consent.optooki.com/s/YOUR-SITE-ID.js"></script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){ /* … */ })(window,document,'script','dataLayer','GTM-XXXX');</script>

This way, the banner controls both the container’s tags and the scripts written directly in the site’s code.

optooki_consent trigger

Some tags do not know Consent Mode (advertising pixels, chat tools…). On each choice, Optooki pushes the optooki_consent event to the dataLayer, with the state of each category in the optooki variable.

  1. Create a variable

    Variables, New, type “Data Layer Variable”, name optooki.marketing (or optooki.analytics, optooki.preferences).

  2. Create the trigger

    Triggers, New, type “Custom Event”, event name optooki_consent, with the condition “the variable equals true”.

  3. Attach it to the tag

    The tag now only fires once the visitor has agreed to that category.

Optooki tag template

If you cannot change the site’s code, the Optooki tag template installs the banner from your container. It sets the default state, everything denied, before all other tags, then loads the banner.

  1. Download the template

    The optooki-google-tag-manager.tpl file is on the Integrations page.

  2. Import it into your container

    In Google Tag Manager: Templates, Tag Templates, New, then the menu at the top right, Import. Choose the file and save.

  3. Create the tag

    Tags, New, type “Optooki - Bandeau de consentement (CMP)”. Paste the server URL and the site ID (Installation tab of the dashboard), then choose the Consent Initialization - All Pages trigger.

  4. Publish the container

    Check in Preview mode first: the banner shows and Google tags wait for the visitor’s choice.

In the same section : Install

Your cookie banner, ready before your next coffee.

Create your account, customise the banner and add one line of code. Free for one site, no credit card required.