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.
Other tags wait for a consent event
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.
| Event | Cookiemark pushes it when |
|---|---|
cookiemark_consent_preferences | Preferences is allowed. |
cookiemark_consent_statistics | Statistics is allowed. |
cookiemark_consent_marketing | Marketing 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
- Under Triggers, create a trigger of the type Custom Event.
- Enter
cookiemark_consent_marketingas the event name and save it as "Cookiemark, marketing allowed". - Create a Custom HTML tag and paste the pixel code that Meta gives you.
- Under Consent Settings, choose Require additional consent for tag to fire and add
ad_storage. - 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.
| Push | When |
|---|---|
consent, default | As soon as the script runs, on every page, when Consent Mode is on. |
consent, update | Straight after the default for a returning visitor, and after every choice. |
cookiemark_consent_ready | Once per page view, when Cookiemark knows the state. For a new visitor everything is still denied. |
cookiemark_consent_update | After every choice the visitor makes. |
cookiemark_consent_preferences and the other two | Once 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'
}| Variable | Use |
|---|---|
cookiemark_consent | An object. Read one category with the variable name cookiemark_consent.marketing. |
cookiemark_consent_state | The allowed categories between vertical bars. When nothing is allowed it is a single bar. |
cookiemark_consent_id | The 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 for three common form tools. It is on unless you switch off Send form events.
| Event | When |
|---|---|
cookiemark_form_sent | A form was sent. Use this one for a conversion. Contact Form 7, Gravity Forms and HubSpot forms all push it. |
cookiemark_form_submit | A visitor pressed send on a Contact Form 7 form, whatever happened next. |
cookiemark_form_invalid | A Contact Form 7 field was filled in wrongly. |
cookiemark_form_spam | Contact Form 7 held the form back as spam. |
cookiemark_form_failed | Contact Form 7 accepted the form, but the mail could not be sent. |
Each event carries cookiemark_form_id, cookiemark_form_status and cookiemark_form_plugin. The last one says contact-form-7, gravity-forms or hubspot. 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.
- Download the template. The file is
cookiemark-consent-mode.tpl. - 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.
- Create a tag of the type Cookiemark - Consent Mode, and fire it on Consent Initialization - All Pages.
- In Cookiemark, open the site, then Google and GTM, and switch Google Consent Mode off. Otherwise the defaults are set twice.
- 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.
| Field | Default | What to enter |
|---|---|---|
| Consent cookie name | cookiemark_consent | Leave it as it is. |
| Consent version | 1 | The same number as the consent version of your site, shown under Settings, Ask everyone again. |
| Category per consent type | The standard mapping | Which category grants each Google signal. |
| Wait for update | 500 | Milliseconds that Google tags wait for an update. |
| Regions | Empty | Leave empty to deny everywhere, or enter the countries where you show the banner. |
| Ads data redaction and URL passthrough | On and off | The 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.
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.
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.
| Event | Cookiemark pushes it |
|---|---|
cookie_consent_preferences | Together with cookiemark_consent_preferences. |
cookie_consent_statistics | Together with cookiemark_consent_statistics. |
cookie_consent_marketing | Together with cookiemark_consent_marketing. |
cookie_consent_update | After every choice, and when a page loads for a visitor with a stored choice. |
- Note the exact event names the triggers in your container listen to.
- Pause the Cookiebot tag in the container and remove the Cookiebot script from the site. Two consent tools on one page fight each other.
- Add the Cookiemark line and switch on Also send Cookiebot event names.
- 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.
- 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.