Connect your cookie banner
Connect the Pixel to Iubenda, Cookiebot or your own banner without changing the setup you already have.
Your cookie banner (also called a CMP, Consent Management Platform) collects the visitor's choices. The Pixel stays paused until it receives that choice, then follows it. To make this work, you add a small “bridge” to the banner that passes the choice to the Pixel: the dashboard prepares it for you.
The bridge doesn't load the banner or change its configuration: it hooks into the banner already on your site.
Where to find it in the dashboard
Open Setup → Pixels, select the Pixel, then Settings → Privacy and consent. In the Make your pixel GDPR-ready section, choose your provider: Iubenda, Cookiebot or Custom banner.
Script order doesn't matter
The CJM Pixel must be installed on the same pages as the banner. The bridge waits up to 5 seconds for the Pixel to load, so it doesn't matter which script loads first.
Connect your banner
Open your Iubenda code
Find the Iubenda snippet already on your site — the one with _iub.csConfiguration = { … }. Keep it as it is: you'll only add a few lines.
Check the purpose IDs
Iubenda identifies each consent category by a number. The defaults match a standard Iubenda setup; change them in the dashboard only if your Cookie Solution numbers them differently.
| Dashboard field | Default | What it controls |
|---|---|---|
| Measurement purpose ID | 4 | Statistics (analytics_storage) |
| Marketing / Advertising purpose ID | 5 | Advertising (ad_storage, ad_user_data, ad_personalization) |
Paste the CJM block into the callback
The dashboard asks whether your configuration already contains onPreferenceExpressedOrNotNeeded. Choose Yes, it does or No, it doesn't and copy the matching code.
Yes, it does. Paste the CJM block at the start of the function, above your existing code:
_iub.csConfiguration = {
"siteId": 1234567,
// …
"callback": {
"onPreferenceExpressedOrNotNeeded": function (preference) {
// ▶ paste the CJM block here
// …your existing code stays below
}
}
};// CJM consent bridge
(function (preference) {
var p = preference && preference.purposes;
var measurement = !preference || (p ? p["4"] === true : preference.consent === true);
var marketing = !preference || (p ? p["5"] === true : preference.consent === true);
var signals = {
analyticsStorage: measurement ? "granted" : "denied",
adStorage: marketing ? "granted" : "denied",
adUserData: marketing ? "granted" : "denied",
adPersonalization: marketing ? "granted" : "denied"
};
(function send(attempt) {
if (window.CJMPixel) return window.CJMPixel.updateConsent(signals, { source: "iubenda" });
if (attempt < 50) setTimeout(function () { send(attempt + 1); }, 100);
})(0);
})(preference);
// END CJM consent bridgeNo, it doesn't. Add the whole callback property inside _iub.csConfiguration, for example after "banner": { … },. If you already have a callback object with other handlers, copy only the onPreferenceExpressedOrNotNeeded function into it.
"callback": {
"onPreferenceExpressedOrNotNeeded": function (preference) {
// CJM consent bridge
(function (preference) {
var p = preference && preference.purposes;
var measurement = !preference || (p ? p["4"] === true : preference.consent === true);
var marketing = !preference || (p ? p["5"] === true : preference.consent === true);
var signals = {
analyticsStorage: measurement ? "granted" : "denied",
adStorage: marketing ? "granted" : "denied",
adUserData: marketing ? "granted" : "denied",
adPersonalization: marketing ? "granted" : "denied"
};
(function send(attempt) {
if (window.CJMPixel) return window.CJMPixel.updateConsent(signals, { source: "iubenda" });
if (attempt < 50) setTimeout(function () { send(attempt + 1); }, 100);
})(0);
})(preference);
// END CJM consent bridge
}
},Visitors outside the regions where Iubenda asks for consent are tracked normally.
Check that it works
Follow the check at the bottom of the page.
Check that it works
- Open your site in a private window.
- Answer the banner, for example by accepting statistics only.
- Open the browser console and run:
CJMPixel.getConsentState();
// → { signals: { analyticsStorage: "granted", adStorage: "denied", ... }, source: "...", expressedAt: "..." }The signals must match your choice. Repeat the test with a rejection, a return visit and a change of mind from the preferences link. If the signals stay unspecified, the bridge didn't run: check that you pasted it in the right place and that the Pixel is on the page.
Alternative: Google Tag Manager
If you'd rather not edit your site, open Prefer Google Tag Manager? under the Iubenda or Cookiebot instructions and publish the tags from the dashboard.