Marketing · Gutenberg

Cookie Consent block for WordPress

GDPR-compliant cookie consent banner with customizable position, layout, categories, and GTM integration.

Get Blockenberg

Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.

Get Blockenberg

What it actually does

GDPR-compliant cookie consent banner with customizable position, layout, categories, and GTM integration.

Inspector panels on this block: Message & Buttons, Cookie Categories, Position & Layout, Cookie Settings, Banner Colors, Button Colors. Those titles come from index.js, not from a shared template.

Behavior controls: “Show Customize Button” (Expands cookie category toggles); “Banner Position” options: Bottom Bar, Top Bar, Bottom-Left Corner, Bottom-Right Corner; “Layout Style” options: Bar (inline), Popup (stacked); “Entry Animation” options: Slide, Fade, None.

Where to find it

Gutenberg inserter → Marketing → search “Cookie Consent” (block name `blockenberg/cookie-consent` in block.json). Style it in the sidebar after insert.

How to use Cookie Consent block for WordPress

  1. Install Blockenberg. Install from WordPress.org and activate the plugin.
  2. Insert the block. Edit a page, click +, search for “Cookie Consent”, insert it. Category: Marketing.
  3. Configure inspector controls that exist on this block. Open Message & Buttons. Set “Consent Message”, “Accept Button Text”, “Show Decline Button”, “Decline Button Text”.
  4. Check the published page. The view script reads HTML data attributes: data-animation, data-bkbg-cc-accept, data-bkbg-cc-category, data-bkbg-cc-customize, data-bkbg-cc-decline, data-bkbg-cc-save, data-cookie-days, data-cookie-name. The block editor preview may not run the same view script.

Inspector controls from this block’s code

ControlWhat the code does
Consent MessageMultiline text field in the inspector. block.json default: We use cookies to enhance your experience, analyze site traffic, and serve personalized content. By clicking "Accept All", you consent to our use of cookies.. Saved as `message`.
Accept Button TextText field in the inspector. block.json default: Accept All. Saved as `acceptLabel`.
Show Decline ButtonOn/off toggle in the inspector. On by default. Saved as `showDecline`.
Decline Button TextText field in the inspector. block.json default: Decline. Saved as `declineLabel`.
Show Customize ButtonOn/off toggle in the inspector. Expands cookie category toggles. Off by default. Saved as `showCustomize`.
Customize Button TextText field in the inspector. block.json default: Customize. Saved as `customizeLabel`.
Privacy Policy Link TextText field in the inspector. block.json default: Privacy Policy. Saved as `privacyLabel`.
Privacy Policy URLText field in the inspector. Saved as `privacyUrl`.
Analytics CookiesOn/off toggle in the inspector. On by default. Saved as `showAnalytics`.
Analytics LabelText field in the inspector. block.json default: Analytics. Saved as `analyticsLabel`.
Marketing CookiesOn/off toggle in the inspector. On by default. Saved as `showMarketing`.
Marketing LabelText field in the inspector. block.json default: Marketing. Saved as `marketingLabel`.
Functional CookiesOn/off toggle in the inspector. On by default. Saved as `showFunctional`.
Functional LabelText field in the inspector. block.json default: Functional. Saved as `functionalLabel`.
Banner PositionSelect control; the chosen value is saved on the block. Options: Bottom Bar; Top Bar; Bottom-Left Corner; Bottom-Right Corner. block.json default: bottom. Saved as `position`.
Layout StyleSelect control; the chosen value is saved on the block. Options: Bar (inline); Popup (stacked). block.json default: bar. Saved as `layout`.
Entry AnimationSelect control; the chosen value is saved on the block. Options: Slide; Fade; None. block.json default: slide. Saved as `animation`.
Max Width (px)Numeric range control in the inspector. Range 320–1400. block.json default: 900. Saved as `maxWidth`.
Border Radius (px)Numeric range control in the inspector. Range 0–24. block.json default: 10. Saved as `borderRadius`.
Padding (px)Numeric range control in the inspector. Range 8–40. block.json default: 16. Saved as `padding`.
Cookie NameText field in the inspector. Key used to store consent in localStorage. block.json default: bkbg_cookie_consent. Saved as `cookieName`.
Remember Consent (days)Numeric range control in the inspector. Range 1–730. block.json default: 365. Saved as `cookieDays`.
MessageShared Blockenberg typography popover (family, size, weight, spacing). Saved as `typoMessage`.
Banner Colors — BackgroundColor control in the inspector. block.json default: #1f2937. Saved as `bgColor`.
Banner Colors — TextColor control in the inspector. block.json default: #f9fafb. Saved as `textColor`.
LinkColor control in the inspector. block.json default: #93c5fd. Saved as `linkColor`.
Accept BackgroundColor control in the inspector. block.json default: #2563eb. Saved as `acceptBg`.
Accept TextColor control in the inspector. block.json default: #ffffff. Saved as `acceptColor`.
Decline TextColor control in the inspector. block.json default: #9ca3af. Saved as `declineColor`.
Decline BorderColor control in the inspector. block.json default: #4b5563. Saved as `declineBorderColor`.

What the front-end script actually does

When this is the right block

Notes from the implementation

viewScript: this folder’s frontend.js is enqueued on the front end for this block.

FAQ

How do I add the Cookie Consent block in WordPress?

Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “Cookie Consent”. It sits under Marketing. After insert, open Message & Buttons and set “Consent Message”, “Accept Button Text”, “Show Decline Button”, “Decline Button Text”.

Where does Cookie Consent store visitor state?

In localStorage on that browser. Clearing site data resets it. It is not a WordPress user meta field unless render.php says so.

Is the Cookie Consent Gutenberg block free?

Yes. Cookie Consent ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.

Can I style Cookie Consent to match my theme?

Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Message & Buttons, Cookie Categories, Position & Layout, Cookie Settings).

Related marketing blocks

Get Blockenberg

Install Blockenberg from WordPress.org, then insert Cookie Consent from the Gutenberg inserter.

Get Blockenberg