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_vendors_offWith the choice per provider switched on (paid): the providers the visitor switched off, by id, such as meta-pixel.
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_startA visitor filled in the first field of a form, once per form on a page.
cookiemark_form_sentA form was sent successfully. 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_invalidThe form tool refused a field that was filled in wrongly.
cookiemark_form_spamThe form tool held the form back as spam.
cookiemark_form_failedThe form tool took the form but could not finish it, such as a mail that could not be sent or a server error.
cookiemark_form_abandonA visitor started a form and left the page without sending it. Left through a link to another page of the site, it is pushed on that next page.

The form tools that report a successful submission, 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
Jetpack FormsjetpackThe form ID
SureFormssureformsThe form ID
MailPoetmailpoetThe form ID
Mailchimp for WPmc4wpThe form 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
Webflow formswebflowThe form's element ID, else its name
Squarespace forms and newsletter blockssquarespaceThe form ID
Shopify contact and newsletter formsshopifycontact or customer, as Shopify names the form

A Gravity Forms form without AJAX pushes cookiemark_form_sent once its confirmation or the page it sends to shows. A form that loads a new page after sending, as a plain HTML form does, pushes cookiemark_form_sent with cookiemark_form_via set to leave: on the page it loads when that is a page of the site, otherwise as the browser sends it. That is so for a form sent to another site or a new tab, and to a script such as mail.php or an /api/ address, which answers without the site's pages. Cookiemark cannot see what the site answers, so this also counts a form the site then turns down. A trigger on the thank-you page counts only the ones that went through. Use one of the two, or each form counts twice. 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.

A form that sends to a form service names that service in cookiemark_form_plugin: basin, formcarry, formspree, formsubmit, google-forms, mailchimp, mailerlite, netlify or web3forms. cookiemark_form_id holds the form's ID at that service. Web3Forms and FormSubmit give a form no ID, so for those it holds the form's own name or id, and is empty when the form has neither. It pushes cookiemark_form_sent once the page shows that the form went through, as any other form does.

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 keys of a form event

Every event of Cookiemark also has cookiemark_event_id, one of its own, with cookiemark_source and cookiemark_version. Tag Manager keeps a key until a later push sets it again, so Cookiemark sets every key of an event on every push, empty when it has no value: nothing of an earlier form ends up with a later one.

KeyWhat it holds
cookiemark_form_pluginThe form tool, as in the table above, or form for a form of no known tool.
cookiemark_form_idThe form's ID, always as text, also where the tool uses a number.
cookiemark_form_keyThe tool and the ID together, such as contact-form-7:12, for a trigger with one condition.
cookiemark_form_nameThe form's heading or name, when it has one.
cookiemark_form_statusHow it went, always one of: start, submit, sent, invalid, spam, failed, abandon.
cookiemark_form_tool_statusThe tool's own word for it, such as mail_sent, when the tool gives one.
cookiemark_form_viaOn a sent: how Cookiemark saw that the form was sent successfully.
cookiemark_form_fieldsThe kinds of fields the form has, never what was typed.
cookiemark_form_userOn a sent of a form whose tags send customer data: SHA-256 hashes of the e-mail address and phone number, each null when the form has none, and only with consent for ad user data.
cookiemark_form_fieldOn an abandon: the name of the field the visitor was in last.
cookiemark_form_pageThe path of the page the form was on, when the event comes on another page.
cookiemark_form_langThe language of the page.

Clicks, bookings, chats and thank-you pages

EventWhen
cookiemark_clickA click on a phone number, e-mail address, WhatsApp link, file, route or order platform, or a phone number or e-mail address of the site that a visitor copied. cookiemark_click_type is tel, mailto, whatsapp, download, directions, outbound, copy_tel or copy_mailto; cookiemark_click_target holds the number, address, file name or platform. cookiemark_click_text holds the text of the link, and cookiemark_click_url where a file, route or platform link goes, without its query. A copied number or address the site does not link to counts with cookiemark_click_target empty, as it may be the visitor's own.
cookiemark_bookingA booking was made through a booking tool on the page. cookiemark_booking_tool and cookiemark_booking_name say which tool; the service, start, duration, value, currency, staff, location and guests follow as far as the tool tells the page. cookiemark_booking_user holds hashes as cookiemark_form_user does. cookiemark_booking_id is the service or event type in the tool, cookiemark_booking_ref its own reference hashed, cookiemark_booking_status the tool's own word for the booking and cookiemark_booking_via how Cookiemark saw it.
cookiemark_chatA chat was opened, a visitor sent the first message, or left their details in it. cookiemark_chat_tool and cookiemark_chat_name say which tool, cookiemark_chat_moment is opened, started or lead. What anybody wrote is never read.
cookiemark_page_conversionA visit to a thank-you page: one of the tracking setup, or a page whose address reads as one, such as /thank-you/ or /bedankt/. cookiemark_page_type is thank_you, or order for an order page; cookiemark_page_path, cookiemark_page_title and cookiemark_page_lang say which page; when a form led to it, the form keys say which form.

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 domain, 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 domain, 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.

Connect Google

To check and fix your container, and to put tracking in it, Cookiemark needs a connection to the Google account that manages it. One connection serves every domain of your organisation.

  1. An owner or admin presses Connect Google: on a domain under Google and GTM or Tracking, or under Settings, Integrations.
  2. Sign in with the Google account that manages the Tag Manager container of your site. Cookiemark can do in Tag Manager only what that account may do, so to publish, the account needs permission to publish the container.
  3. Google asks you to let Cookiemark see, edit and publish your Tag Manager containers. That is all we ask for: no access to Analytics, Google Ads or anything else in your Google account.
  4. Back in Cookiemark, choose the container of the site on the Google and GTM tab. Cookiemark opens on the container the scan found, if it found one.

No container for this site yet? Choose the Tag Manager account and press Create container. Cookiemark makes a web container named after your domain and connects it. When your site loads no container yet, the Cookiemark script loads the new one once you publish your settings, so you add nothing to the site. Creating a container needs Administrator access to the Tag Manager account. A Tag Manager account itself you create at tagmanager.google.com.

Tag Manager, Analytics and Google Ads each have a connection of their own, so each can use another Google account, for example a Google Ads test account. We keep every connection encrypted. Disconnect under Settings, Integrations ends one: we delete the key we kept, and withdraw our access at Google when no other connection uses that Google account. Deleting your organisation ends them all.

Let Cookiemark fix your container

Instead of checking 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. The GTM Fixer, which checks and fixes, is on every plan.

  1. Open the domain, 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 Discard to remove the changes from the workspace without anything going live.

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.