Start freeDashboard
Documentation

Google Tag Manager

Tag Manager runs the tags; Cookiemark tells it what the visitor allowed. This page shows how the two work together, so every tag in your container respects the choice.

Who loads the container

The Container ID field on the Google and GTM tab decides this.

  • You enter your container ID. Cookiemark loads the container itself, directly after the consent defaults. Remove every other Tag Manager snippet from the site, in your theme, an app or a plugin. If the same container is already on the page, Cookiemark does not load it a second time.
  • You leave it empty. Cookiemark loads nothing and talks to your container through the data layer. Keep your own snippet below the Cookiemark line, or Google tags start before the defaults.

Cookiemark adds the script part of Tag Manager only, not the <noscript> part.

Google tags need no changes

Google's own tags have consent checks built in. That covers the Google tag for GA4, Google Ads conversion and remarketing tags, Floodlight and the Conversion Linker. They read the consent state that Cookiemark sets and adjust what they store and send.

Leave their Consent Settings on No additional consent required, and keep the trigger you normally use. To see the consent settings of all tags at once, switch on Enable consent overview under Admin, Container Settings.

A tag from another vendor knows nothing about Consent Mode. The Meta Pixel, the LinkedIn Insight Tag, Hotjar and any Custom HTML tag fire whenever their trigger fires. Give these tags a trigger on the events Cookiemark pushes to the data layer.

EventCookiemark pushes it when
cookiemark_consent_preferencesPreferences is allowed.
cookiemark_consent_statisticsStatistics is allowed.
cookiemark_consent_marketingMarketing is allowed.

Each event arrives once per page view. For a returning visitor that happens when the page loads. For a new visitor it happens the moment they choose.

Example: the Meta Pixel

  1. Under Triggers, create a trigger of the type Custom Event.
  2. Enter cookiemark_consent_marketing as the event name and save it as "Cookiemark, marketing allowed".
  3. Create a Custom HTML tag and paste the pixel code that Meta gives you.
  4. Under Consent Settings, choose Require additional consent for tag to fire and add ad_storage.
  5. Choose the trigger from step 2 and save the tag.

The trigger and the consent check do different jobs. The trigger decides when the tag runs: once marketing is allowed, on this page and every later one. The consent check is a second lock, in case somebody adds another trigger to the tag later.

Do not rely on the consent check alone with an All Pages trigger. Tag Manager blocks the tag when that trigger fires without consent, and a blocked tag does not run later by itself. A new visitor who accepts would then be missed until their next page.

Tags that fire on other events

A purchase or form tag keeps its own trigger. Add the consent check from step 4 to it, or add a condition to its trigger: cookiemark_consent_state contains |marketing|.

Data layer events and variables

Cookiemark pushes to dataLayer. If your container uses another name, enter it under Data layer name.

PushWhen
consent, defaultAs soon as the script runs, on every page, when Consent Mode is on.
consent, updateStraight after the default for a returning visitor, and after every choice.
cookiemark_consent_readyOnce per page view, when Cookiemark knows the state. For a new visitor everything is still denied.
cookiemark_consent_updateAfter every choice the visitor makes.
cookiemark_consent_preferences and the other twoOnce per page view, for each category that is allowed.

After a choice the order is fixed: the consent update first, then cookiemark_consent_update, then one event for each category that was not allowed before. The ready and update events carry three values.

{
  event: 'cookiemark_consent_update',
  cookiemark_consent: { necessary: true, preferences: false, statistics: true, marketing: true },
  cookiemark_consent_state: '|statistics|marketing|',
  cookiemark_consent_id: '0b0f6c1e-3d0a-4c54-9f0e-2f1c8a4e7b11'
}
VariableUse
cookiemark_consentAn object. Read one category with the variable name cookiemark_consent.marketing.
cookiemark_consent_stateThe allowed categories between vertical bars. When nothing is allowed it is a single bar.
cookiemark_consent_idThe visitor's consent ID, the same one as in the consent log. Empty until they choose.

Create these as variables of the type Data Layer Variable. They have a value from cookiemark_consent_ready onwards.

Form events

Tag Manager cannot see by itself that a visitor sent a form when the page does not reload. Cookiemark pushes an event when a form is sent. It says which form and how it went, never what was typed. It is on unless you switch off Send form events.

EventWhen
cookiemark_form_sentA form went through. Use this one for a conversion. The form tools in the list below push it.
cookiemark_form_submitA visitor pressed send, whatever happened next. Every form on the page pushes it, so it is the event to use for a form tool that is not in the list.
cookiemark_form_invalidA Contact Form 7 field was filled in wrongly.
cookiemark_form_spamContact Form 7 held the form back as spam.
cookiemark_form_failedContact Form 7 accepted the form, but the mail could not be sent.

The form tools that report a form that went through, and what cookiemark_form_id holds for each:

Form toolcookiemark_form_plugincookiemark_form_id
Contact Form 7contact-form-7The form ID
WPFormswpformsThe form ID
Gravity Forms (AJAX forms)gravity-formsThe form ID
Elementor Pro formselementorThe form widget's ID
Fluent Formsfluent-formsThe form ID
Ninja Formsninja-formsThe form ID
Formidable FormsformidableThe form ID
ForminatorforminatorThe form ID
Breakdance formsbreakdanceThe form ID
Bricks formsbricksThe Bricks element ID
Kadence Blocks formskadenceThe block ID
Spectra formsspectraThe block ID
Otter Blocks formsotterThe form block's id
Everest Formseverest-formsThe form ID
HappyFormshappyformsThe form ID
MetFormmetformEmpty: MetForm does not say which form
QuformquformThe form ID
weFormsweformsThe form ID
WS Formws-formThe form ID
Avada formsavadaThe form ID
HubSpot formshubspotThe form ID

A form that loads a new page after sending, such as a Gravity Forms form without AJAX, Divi's contact form or a Jetpack form, only pushes cookiemark_form_submit. To count the ones that went through, add a trigger on the thank-you page in Tag Manager. For any other form, cookiemark_form_plugin says form and cookiemark_form_id holds its name, its id or the address it sends to. To count one form only, add the condition that cookiemark_form_id equals its ID.

The events never contain what the visitor typed. A name or an email address in the data layer can be read by every tag in the container, also before the visitor has chosen.

The template

Choose the template when you want Tag Manager, not the Cookiemark script, to set the Consent Mode defaults. Cookiemark still shows the banner, stores the choice and pushes the events. Only the defaults and updates move to your container.

  1. Download the template. The file is cookiemark-consent-mode.tpl.
  2. In Tag Manager, open Templates and press New under Tag Templates. Open the menu at the top right, choose Import, pick the file and save.
  3. Create a tag of the type Cookiemark - Consent Mode, and fire it on Consent Initialization - All Pages.
  4. In Cookiemark, open the site, then Google and GTM, and switch Google Consent Mode off. Otherwise the defaults are set twice.
  5. Under Cookies, switch the Google Tag Manager service off, so the container can load before a choice.

Try the import in a test container first. It costs nothing, and an import can behave differently in your account.

FieldDefaultWhat to enter
Consent cookie namecookiemark_consentLeave it as it is.
Consent version1The same number as the consent version of your site, shown under Settings, Ask everyone again.
Category per consent typeThe standard mappingWhich category grants each Google signal.
Wait for update500Milliseconds that Google tags wait for an update.
RegionsEmptyLeave empty to deny everywhere, or enter the countries where you show the banner.
Ads data redaction and URL passthroughOn and offThe same as the settings of that name in Cookiemark.

The tag sets every signal to denied, except security_storage. It then reads the cookiemark_consent cookie, and sends a stored choice as an update before other tags fire. For later choices it adds itself to window.cookiemarkListeners, and Cookiemark calls it after every choice.

Loading Cookiemark from Tag Manager

Some sites only let you add things through Tag Manager, not in the head of the page. Then the template can load Cookiemark as well: switch on Also load the Cookiemark script from this tag and enter the site key, the part between /s/ and .js in the line on the Install tab. The tag sets the defaults first and loads the script straight after, on Consent Initialization.

Do this only when the line in the head is not possible. Loaded from Tag Manager, Cookiemark starts later and cannot hold back scripts that are in the page's own HTML, such as a pixel pasted into the theme. Only the tags in this container wait for consent, through the consent checks and the triggers above. The banner, the stored choice, the consent log and the events work as usual.

What you take on with the template

  • The consent version lives in two places. When you ask everyone again in Cookiemark, raise the number in the tag as well. Until you do, the tag ignores stored choices.
  • The mapping of categories to signals lives in two places too. The tag uses its own.
  • The template tests live under Tests in the template editor, if you want to see how it behaves.

Let Cookiemark fix your container

Instead of going through every tag by hand, you can connect the Google account that manages your container. Cookiemark checks every tag in the version that is live and shows only what is wrong. You see each change before anything goes live. Fixing comes with paid sites; the check is there on every plan.

  1. Open the site, then Google and GTM, and press Connect Google. An owner or admin can do this, here or under Settings, Integrations. We ask only for access to Tag Manager, and you can disconnect at any time.
  2. Cookiemark opens on the container your scan found, or the one you chose before. To pick another, press Choose another container, then choose the Tag Manager account and the container. Both lists can be searched.
  3. Under Consent in Google Tag Manager you see every tag that runs without waiting for consent, what it does now and what it would wait for after the fix.
  4. Press Prepare the fix in a workspace. Cookiemark puts the changes in a new workspace in Tag Manager, named after the date and time. Nothing is live yet: open Preview in Tag Manager to look at it, or test it on your site with Tag Manager's own preview.
  5. Press Publish. Cookiemark publishes a new container version and starts a quick scan to check the result. To undo it, publish the previous version in Tag Manager. Or press Throw away and the workspace is deleted without anything changing.

What the fix changes:

  • Tags that are not from Google, such as Meta, LinkedIn, TikTok, Hotjar, Leadinfo or a Custom HTML tag, get additional consent for their category: marketing waits for ad_storage, ad_user_data and ad_personalization, statistics for analytics_storage, following your mapping on this tab.
  • When Consent Mode starts too late, the fix adds the Cookiemark template on Consent Initialization, so it runs before every other tag, and switches Consent Mode off in the Cookiemark script in the same step, so the defaults are not set twice.
  • Google's own tags are left alone: Consent Mode already covers them.

How Cookiemark knows what a tag is

A tag is recognised by the services Cookiemark knows, by domains we researched for all customers, and by an open database of more than 4,500 tracker domains. A tag we still do not recognise waits for marketing consent, the strictest choice, so it never runs before the visitor agrees. If your site needs it to work, a chat for example, choose Necessary in the list next to it before you prepare the fix.

When you change the category of a tag we did not recognise, we note the domain it loads from and your choice, without anything else about you or the tag. Once we have checked such a suggestion, Cookiemark recognises that domain for everyone.

What you can look back on

Every fix stays under Changes in Google Tag Manager on the same tab: when it was published, as which container version, and for each tag what it did before and after.

Tracker domains from WhoTracks.me (CC BY 4.0) and AdGuard CompaniesDB (CC BY-SA 4.0).

Moving a container built for Cookiebot

A Cookiebot container usually fires its tags on events with Cookiebot's names. Switch on Also send Cookiebot event names on the Google and GTM tab, and Cookiemark pushes those names as well.

EventCookiemark pushes it
cookie_consent_preferencesTogether with cookiemark_consent_preferences.
cookie_consent_statisticsTogether with cookiemark_consent_statistics.
cookie_consent_marketingTogether with cookiemark_consent_marketing.
cookie_consent_updateAfter every choice, and when a page loads for a visitor with a stored choice.
  1. Note the exact event names the triggers in your container listen to.
  2. Pause the Cookiebot tag in the container and remove the Cookiebot script from the site. Two consent tools on one page fight each other.
  3. Add the Cookiemark line and switch on Also send Cookiebot event names.
  4. Open Tag Manager's preview, load the site in a private window and accept everything. Check that events with the names from step 1 arrive and that your tags fire.
  5. Where a name differs, change the trigger to the matching cookiemark_consent_ event.

A variable that reads Cookiebot's own cookie, called CookieConsent, finds nothing, because Cookiemark does not set it. Use cookiemark_consent_state instead. Code that asks Cookiebot.consent.marketing needs the setting Answer to the Cookiebot JavaScript API, described in the JavaScript API.

Once every trigger uses the Cookiemark names, you can switch the Cookiebot names off again.