Tag managers and CDPs
The hosted banner can be installed through Google Tag Manager, and it can tell Google Tag Manager and your customer data platform (CDP) what each visitor decided.
Install the banner through Google Tag Manager
-
In Google Tag Manager, create a Custom HTML tag named "Bytemonk Consent".
-
Paste this, with your own host and publishable key:
<script>(function () {var s = document.createElement('script');s.src = 'https://<your-bm-api-host>/widget/v1/consent.js';s.async = true;s.setAttribute('data-org-key', '<your publishable key>');s.setAttribute('data-google-consent-mode', 'true');s.setAttribute('data-datalayer-events', 'true');document.head.appendChild(s);})();</script> -
Set the trigger to Consent Initialization - All Pages, so the banner and its default "denied" signals load before your other tags.
-
Turn on Enable consent overview in the container settings, and set each tag's consent requirements (for example
analytics_storagefor analytics tags). Tags then wait for the visitor's choice.
Every other setting (layout, colours, labels, auto-blocking) still comes from the Cookie Manager. Keep
data-auto-block off, or leave the tag-manager-loaded tags to Consent Mode, so the two do not both hold the same tag.
Fire tags on a decision
With data-datalayer-events="true" the banner pushes this to dataLayer every time the visitor decides, and once when a
returning visitor's saved decision is restored:
{
"event": "bytemonk_consent_update",
"bytemonk_consent": { "strictly_necessary_cookies": true, "analytics_cookies": true, "advertising_cookies": false },
"bytemonk_notice_id": 12
}
Create a Custom Event trigger named bytemonk_consent_update, and a Data Layer Variable for
bytemonk_consent.analytics_cookies (use your own purpose codes) to fire a tag only when that purpose is true.
Tell your CDP
Add data-cdp to the banner's script tag. Each call is made once per decision, and also when a returning visitor's decision is
restored. If the CDP's own script is still loading, the banner waits up to about ten seconds for it.
data-cdp | What is sent |
|---|---|
segment | analytics.track("Segment Consent Preference Updated", {}, { context: { consent: { categoryPreferences } } }), where categoryPreferences maps each purpose code to true or false. Use your purpose codes as the category IDs in Segment. |
rudderstack | rudderanalytics.track("Bytemonk Consent Updated", { purposes, source: "bytemonk" }). |
List both with data-cdp="segment,rudderstack". For any other tool, listen for the bytemonkConsentUpdated browser event
(event.detail.purposeSelections) and forward it yourself, or subscribe a server to the
consent.granted and consent.withdrawn webhooks.