Cookiebot dialogs, declined the way a visitor would decline them
Cookiebot is common on mid-sized European sites and exposes a JavaScript API. The autopilot uses the decline button when it is there and the API when it is not, and treats a dialog that is still visible as unanswered.
What happens on a Cookiebot page
Inside a single observe call, before any candidate is collected.
-
Detect
The dialog is recognised by its #CybotCookiebotDialog host. No host, no recogniser: the page is treated like any other.
-
Reject
The decline button (CybotCookiebotDialogBodyButtonDecline or the level opt-in decline-all variant) is pressed. Failing that, Cookiebot.submitCustomConsent(false, false, false) declines preferences, statistics and marketing through the SDK.
-
Confirm
The host must disappear for the action to count. A dialog that is still showing means observe reports an unanswered banner rather than pretending.
-
Collect
Only now are the page’s interactive elements gathered for your agent, so a candidate list never contains the banner’s own buttons.
Recogniser facts
| Detected by | #CybotCookiebotDialog |
|---|---|
| Reject path | Decline button; API fallback submitCustomConsent(false, false, false) |
| Accept path | Allow-all button or submitCustomConsent(true, true, true), only with consent: accept |
| Categories | Preferences, statistics, marketing, in that order in the API call |
| Fallback | Signature mismatch means the recogniser stays silent and the heuristic runs |
| Cost | No inference; the recogniser is a fixed table inside the browser bundle |
As of 2026-09-04
Reject the banner as part of observe
import { Browserberg } from '@browserberg/sdk';
const bb = new Browserberg({
apiKey: process.env.BROWSERBERG_API_KEY,
baseUrl: 'https://browserberg.com',
});
const session = await bb.sessions.create();
// A shop running Cookiebot.
await session.act({ steps: [{ action: 'navigate', value: 'https://shop.example.eu/' }] });
const page = await session.observe({ consent: 'reject' });
// The banner was answered before candidates were collected.
console.log(page.url, page.candidates.length);
Questions engineers ask
Why call the API at all when there is a button?
Some Cookiebot layouts hide the decline button behind a details view. The API route reaches the same consent record without navigating the dialog, and it is only tried when the button is not there.
Will the choice persist across pages in the session?
Cookiebot stores it in its own cookie, so later pages in the same session load without the dialog. A fresh session is a first visit and the dialog returns; the recogniser answers it again.
What does observe return if the dialog cannot be dismissed?
The page as it is, with the banner still present, and a note in the response. It does not guess that the banner is gone.
Does this work in an iframe?
Cookiebot renders in the top document. Banners rendered inside iframes by other CMPs fall to the generic heuristic, which looks inside same-origin frames.
Try it on a Cookiebot site
Five browser hours, no card. One observe call is the whole integration.