Install CookieBeam
Choose the method that fits your stack. CookieBeam supports direct script embeds and a Google Tag Manager (GTM) template. Both initialize Google Consent Mode v2 correctly.
Before you start
- Sign up and create a banner to get your PUBLIC_BANNER_ID.
- Make sure your site allows loading scripts from cdn.cookiebeam.com.
- Publish changes to production when you’re ready.
Option A: Direct Script
- Copy your PUBLIC_BANNER_ID from the CookieBeam dashboard.
- Paste the script as the first element in <head>, loaded synchronously before any other script.
<script id="CookieBeam" src="https://cdn.cookiebeam.com/banner/PUBLIC_BANNER_ID/default/loader.js" type="text/javascript" data-cfasync="false" data-no-optimize="1" data-no-defer="1" data-no-minify="1" data-noptimize="1" nowprocket="1" data-pagespeed-no-defer="1"></script>
This loader sets Consent Mode defaults early and updates consent states after users interact with the banner.
Option B: Google Tag Manager
Prefer the direct script installation to load first and synchronously. The GTM template loads after GTM and does not gate scripts hardcoded outside the container.
- Add the CookieBeam Consent Mode template from the Community Template Gallery.
- Create a new tag from the template.
- Set your Banner ID and use the "Consent Initialization" trigger.