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.
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
- Install Blockenberg. Install from WordPress.org and activate the plugin.
- Insert the block. Edit a page, click +, search for “Cookie Consent”, insert it. Category: Marketing.
- Configure inspector controls that exist on this block. Open Message & Buttons. Set “Consent Message”, “Accept Button Text”, “Show Decline Button”, “Decline Button Text”.
- 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
| Control | What the code does |
|---|---|
| Consent Message | Multiline 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 Text | Text field in the inspector. block.json default: Accept All. Saved as `acceptLabel`. |
| Show Decline Button | On/off toggle in the inspector. On by default. Saved as `showDecline`. |
| Decline Button Text | Text field in the inspector. block.json default: Decline. Saved as `declineLabel`. |
| Show Customize Button | On/off toggle in the inspector. Expands cookie category toggles. Off by default. Saved as `showCustomize`. |
| Customize Button Text | Text field in the inspector. block.json default: Customize. Saved as `customizeLabel`. |
| Privacy Policy Link Text | Text field in the inspector. block.json default: Privacy Policy. Saved as `privacyLabel`. |
| Privacy Policy URL | Text field in the inspector. Saved as `privacyUrl`. |
| Analytics Cookies | On/off toggle in the inspector. On by default. Saved as `showAnalytics`. |
| Analytics Label | Text field in the inspector. block.json default: Analytics. Saved as `analyticsLabel`. |
| Marketing Cookies | On/off toggle in the inspector. On by default. Saved as `showMarketing`. |
| Marketing Label | Text field in the inspector. block.json default: Marketing. Saved as `marketingLabel`. |
| Functional Cookies | On/off toggle in the inspector. On by default. Saved as `showFunctional`. |
| Functional Label | Text field in the inspector. block.json default: Functional. Saved as `functionalLabel`. |
| Banner Position | Select 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 Style | Select control; the chosen value is saved on the block. Options: Bar (inline); Popup (stacked). block.json default: bar. Saved as `layout`. |
| Entry Animation | Select 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 Name | Text 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`. |
| Message | Shared Blockenberg typography popover (family, size, weight, spacing). Saved as `typoMessage`. |
| Banner Colors — Background | Color control in the inspector. block.json default: #1f2937. Saved as `bgColor`. |
| Banner Colors — Text | Color control in the inspector. block.json default: #f9fafb. Saved as `textColor`. |
| Link | Color control in the inspector. block.json default: #93c5fd. Saved as `linkColor`. |
| Accept Background | Color control in the inspector. block.json default: #2563eb. Saved as `acceptBg`. |
| Accept Text | Color control in the inspector. block.json default: #ffffff. Saved as `acceptColor`. |
| Decline Text | Color control in the inspector. block.json default: #9ca3af. Saved as `declineColor`. |
| Decline Border | Color control in the inspector. block.json default: #4b5563. Saved as `declineBorderColor`. |
What the front-end script actually does
- 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.
- It writes to localStorage in the visitor’s browser, not to wp_options.
When this is the right block
- GDPR-compliant cookie consent banner with customizable position, layout, categories, and GTM integration — that is the job of Cookie Consent, not a generic content block.
- Use it when you need the editor control labeled “Consent Message”, which exists on this block’s inspector.
- It matches pages about cookie, gdpr, consent.
- Inserter grouping: landing pages, campaign sections, and conversion layouts.
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
Announcement Strip
A thin dismissible announcement bar — ideal above the site header for promotions, launches, or alerts.
Call to Action
Headline + sub-headline + 1-2 buttons with optional color/gradient background. Perfect inside Row/Column blocks.
CTA Band
Full-width colored band with headline, supporting text and a call-to-action button.
Gradient CTA
A bold full-width call-to-action section with a gradient or solid background, headline, subtitle, and buttons.
Notification Bar
Dismissible sticky announcement or promo bar — shown at the top or bottom of the page.
Promo Banner
Dismissible announcement ribbon with message, link/button, gradient background and cookie memory.
Get Blockenberg
Install Blockenberg from WordPress.org, then insert Cookie Consent from the Gutenberg inserter.