Skip to documentation content

Testing your setup

Use non-production environments, simulated regions, and browser tools to verify that blocking, consent mode, and regional rules work as expected before publishing to production.

Last updated:

Before publishing a banner to production, verify that blocking, consent signals, and regional behavior work as expected. CookieBeam's environment system and the browser's developer tools give you everything you need.

Use environments for safe testing

If your plan includes environments, create a dev or staging environment for your banner. Each environment gets its own CDN URL and its own published configuration, so you can test changes without affecting production visitors.

  1. Open the banner and go to Environments.
  2. Create a dev environment if you don't have one.
  3. Publish your changes to the dev environment.
  4. Load the dev environment's script URL on your test site or local dev server.

Changes published to a dev environment don't touch the production default/ CDN path. When you're satisfied, promote from dev to staging to production, or publish directly to production.

If you don't use environments, test in a private browser window against your production banner. The techniques below work either way.

Verify blocking

Open your site in a clean browser profile (no stored consent cookie) with DevTools open.

  1. Open the Network panel and filter by script type (JS). Load the page.
  2. Check that non-necessary scripts don't fire. Scripts in categories like analytics and marketing should not appear in the network log before you interact with the banner. If they do, the script may be missing a data-category attribute or may not be in the scan inventory.
  3. Accept consent. Click "Accept all" on the banner.
  4. Confirm blocked scripts now load. The network panel should show the previously blocked scripts loading. Check that they execute in the right order; a tag manager should load before the tags it injects.
  5. Revoke consent. Open the preferences panel (through the floating settings button or CookieBeam.showPreferences()), uncheck a category, and save.
  6. Reload the page. Confirm that scripts in the revoked category don't fire.
  7. Check autoClear. If you configured autoClear on a category, open DevTools Application > Cookies after revoking that category. The cookies listed in the autoClear configuration should be gone.

Manual script gating

If you gate scripts with type="text/plain" and data-category in your HTML, check each one:

<script type="text/plain" data-category="marketing" data-src="https://example.com/pixel.js"></script>
  • Before consent: the element should have type="text/plain" and the script should not execute.
  • After accepting marketing: a new script element should appear in the DOM with the real src, and the network panel should show the request.

If you enabled Consent Mode v2, check that the gtag calls fire at the right time.

  1. Open the Console in DevTools. Optionally add a breakpoint or log observer on gtag to capture calls.
  2. Load the page in a clean profile. Look for the consent default call. You should see all keys set; most to denied (in an opt-in region); plus wait_for_update.
  3. Accept consent. Look for the consent update call. The keys for accepted categories should now be granted.
  4. Check the consent cookie. Open Application > Cookies, find cb_cookie, and decode its value (URL-decode, then parse as JSON). The consentMode field should contain a state object mirroring what you saw in the update call.

If you use Google Tag Manager, install the Google Tag Assistant Chrome extension. It shows a timeline of consent state changes and flags tags that fired before consent was resolved.

{
  "consentMode": {
    "v": 1,
    "revision": 3,
    "expiresAt": 1747123456000,
    "state": {
      "ad_storage": "granted",
      "analytics_storage": "granted",
      "security_storage": "granted"
    }
  }
}
  • v should be 1 (the current contract version).
  • state should reflect the visitor's actual category choices, mapped through the category-to-key configuration.
  • revision should match your banner's current revision.
  • expiresAt should be a future timestamp.

Test regional rules

Regional rules change the banner's consent model, buttons, and text per visitor location. Testing them requires simulating different geolocations.

In the dashboard preview

The banner preview in Dashboard → Banners → your banner → Preview lets you pick a simulated country and region. Use it to check each rule without leaving your desk:

  • For an EU country, the banner should show in opt-in mode with "Accept all" and "Reject all" buttons.
  • For California, the banner should show in opt-out mode, possibly with a "Do Not Sell or Share" link.
  • For a country not covered by any rule, the fallback should apply; check whether the banner shows or hides, and which consent model it uses.

On a live page

To test on your actual site:

  • VPN or proxy: connect from the target country. The CDN edge reads the visitor's IP to resolve the country.
  • Geo-override header: if your CDN supports it, set the override header in your request. This depends on your setup.

For each region, verify:

  1. The correct consent model is active (check the banner's buttons).
  2. The banner text matches the regional rule's translation overrides, if any.
  3. The consent record's collectedVia and acceptType match the expected behavior.

Test the fallback

Use a country that no rule covers (try a small nation not in your rule set). The fallback settings should apply: the banner either shows with the fallback consent model, or it hides and grants the fallback's defaultCategories plus readOnly categories (see Regional rules).

Verify privacy signals

To test Global Privacy Control:

  1. Enable the signal. Use a browser extension that sets navigator.globalPrivacyControl = true, or enable the GPC flag in your browser's privacy settings (Firefox: Settings > Privacy & Security > "Tell websites not to sell or share my data"). The property is read-only in most browsers, so assigning it from the Console does not work.
  2. Load the page in a clean profile.
  3. In hard_optout mode: the banner should not auto-show. A toast may appear saying the GPC preference was respected. Open the consent cookie and check for gpcRespected: true.
  4. In preselect_deny mode: the banner should show, but the signal-covered categories should be pre-deselected (unchecked). The visitor can still adjust and save.
  5. Without the signal: repeat the test with GPC off. The banner should behave normally, and gpcRespected should not appear on the consent record.

After each test, inspect the stored consent record to confirm it matches expectations.

In DevTools

  1. Open Application > Cookies and find cb_cookie on your site's domain.
  2. Copy the value and URL-decode it (the browser's console: decodeURIComponent('...')).
  3. Parse the result as JSON.

Key fields to check:

FieldWhat to look for
categoriesThe list of accepted category IDs
acceptTypeall, necessary, or custom: matches the button the visitor clicked
collectedViabanner, preferences, api, or a machine value like default_optout
isDefaultStatetrue for machine-written records, absent or false for explicit choices
isPendingtrue on opt-in default records (nothing non-necessary granted). Also set on opt-out, notice, and hidden-region defaults when Consent Mode's deferMachineDefaults is on
gpcRespectedtrue when GPC shaped the record
revisionShould match the banner's published revision number

Using the Browser API

Instead of reading the cookie directly, use CookieBeam's JavaScript API in the Console:

// Check if a specific category is accepted
CookieBeam.acceptedCategory('analytics');  // true or false

// Get the full preferences object
CookieBeam.getUserPreferences();
// { acceptedCategories: ['necessary', 'analytics', ...],
//   rejectedCategories: ['marketing', ...],
//   acceptedServices: { analytics: ['Google Analytics'] },
//   rejectedServices: { ... } }

See Browser API for the full method list.

Common issues

The banner doesn't show.

  • Check that autoShow is not false in your configuration.
  • Check the visitor's regional rule. If showBanner is false, the banner is hidden for that region and the rule's defaultCategories plus readOnly categories are auto-granted (see What hiding the banner grants).
  • Clear the consent cookie. An existing valid cookie suppresses the banner.
  • Check the Console for errors. A misconfigured translation or missing required field can prevent rendering.

A script still fires after the visitor rejected its category.

  • Verify the script has data-category set to the right category ID, or that it's in the scan inventory under the right category.
  • Scripts hardcoded with <script src="..."> in your HTML (no type="text/plain") execute before CookieBeam can intercept them. Change them to the manual gating pattern.
  • Check for a tag manager that loads the script outside CookieBeam's control.

Google Consent Mode isn't firing.

  • Check that consentMode.enabled is true in the banner configuration.
  • Check that setDefaultsOnLoad is true (it is by default). If false, the consent default call won't fire.
  • Make sure the CookieBeam script loads before gtag.js. Consent Mode defaults must be set before Google tags initialize.

Wrong region detected.

  • The region comes from the CDN edge, which reads the visitor's IP. A VPN or corporate proxy can cause a mismatch.
  • In the dashboard preview, make sure you selected the right simulated country.
  • Check the console for CookieBeam's regional match logging (available in non-production builds).

Consent cookie not appearing.

  • Check the cookie's domain setting. If set to .example.com, it won't appear when testing on localhost.
  • Some browsers block cookies in certain privacy modes. Try a standard private window.
  • Check for cookie size. The consent cookie can grow large with many services and the consentMode snapshot. Browsers reject cookies over 4 KB.