Skip to content
Consent management

Usercentrics banners, answered before your agent looks at the page

Usercentrics is the default CMP for German publishers and renders its dialog inside a shadow root. The consent autopilot pierces it, presses the deny button or calls the SDK, and only then collects the page for your agent.

How the recogniser works

Detected by The #usercentrics-root or #uc-center-container host, or the uc-container test id
Reject path The deny-all button (data-testid uc-deny-all-button); UC_UI.denyAllConsents() as the API route
Accept path The accept-all button, or UC_UI.acceptAllConsents(); only when you pass consent: accept
Shadow DOM The dialog lives in a shadow root, so the recogniser pierces shadow trees before anything else
Considered done when The detected host is gone from the page
When signatures change The recogniser fails safe, does nothing, and the generic heuristic gets its turn

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 German news site running Usercentrics.
await session.act({ steps: [{ action: 'navigate', value: 'https://www.publisher.example/' }] });
const page = await session.observe({ consent: 'reject' });

// The banner was answered before candidates were collected.
console.log(page.url, page.candidates.length);

What reject actually means here

A rejection through the CMP’s own path, not a hidden banner.

The CMP records the decision

The deny button and the SDK call are the same actions a person takes. Usercentrics stores the resulting choice in its own consent record, so the page behaves as it would for a visitor who declined.

Nothing is hidden with CSS

Removing the overlay from view while consent stays unanswered would leave scripts waiting on a decision. The autopilot answers, then checks the host element has really gone.

Version drift fails closed

Usercentrics renames test ids across versions. A selector that no longer matches means the recogniser does not fire; the fallback heuristic looks for a deny button by text, and if it finds none, the banner stays and observe reports it.

Questions engineers ask

Do I need to write anything to handle Usercentrics?

No. consent is an option on observe and defaults to reject. The recogniser runs once per page load before candidates are collected, so your instructions never mention cookies.

What if I need the site to behave as if consent was given?

Pass consent: accept. It is an explicit opt-in, never implied, because consenting on somebody’s behalf is a decision your code should make visibly.

Can I leave the banner alone and handle it myself?

Yes, consent: off. Useful when the banner is what you are testing, or when your own workflow steps drive the dialog.

Is the consent choice visible afterwards?

The observe result reflects the page after the banner was answered, and the session’s action log records the observe. Whether Usercentrics itself logged the choice is the CMP’s job, and it does so as it would for any visitor.

See it on a page you automate

Five browser hours, no card. Open a Usercentrics site and call observe.