Debugging
Use these techniques to diagnose and fix issues with your CookieBoss integration.
Browser Console
Check consent state
javascript
// Current consent categories
window.__cookieboss.getConsent()
// → { necessary: true, analytics: true, marketing: false, functional: true }
// Full configuration
window.__cookieboss.config
// Script version
window.__cookieboss.version Check if script is loaded
javascript
// Returns undefined if script hasn't loaded yet
typeof window.__cookieboss
// → "object" if loaded, "undefined" if not Read the consent cookie directly
javascript
// Parse the consent cookie
const raw = document.cookie
.split('; ')
.find(c => c.startsWith('cookieboss_consent='));
if (raw) {
console.log(JSON.parse(decodeURIComponent(raw.split('=')[1])));
} else {
console.log('No consent cookie found');
}
// Check localStorage fallback
console.log(JSON.parse(localStorage.getItem('cookieboss_consent') ?? 'null')); Check geo cache
javascript
// View cached geo detection result
const geo = JSON.parse(localStorage.getItem('cookieboss_geo') ?? 'null');
console.log(geo);
// → { data: { country: "DE", region: "" }, timestamp: 1708186234567 } Network Tab
Script loading
- Open DevTools > Network tab
- Filter by
consent.js - Verify the script loads with status
200 - Check the Size column — if it says “disk cache” or “memory cache”, it’s a cached version
Analytics beacons
- Filter by
a.cookieboss.io - You should see
POSTrequests when the visitor interacts with the banner - If these fail, check your CSP configuration
Geo detection
- Filter by the geo endpoint (look for requests to
a.cookieboss.iowith a path containing “geo”) - The response should contain
{ country: "XX", region: "YY" }
Elements Panel (Shadow DOM)
The consent banner renders inside a Shadow DOM. To inspect it:
- Open DevTools > Elements tab
- Find the
<div id="cookieboss-container">element - Expand the #shadow-root (open) node
- The banner HTML is inside the shadow root
Shadow DOM elements don’t respond to document.querySelector() from your page’s JavaScript. To access them programmatically, use document.getElementById('cookieboss-container')?.shadowRoot?.querySelector(...).
Google Consent Mode verification
javascript
// Check the dataLayer for consent entries
window.dataLayer.forEach((entry, i) => {
if (Array.isArray(entry) && entry[0] === 'consent') {
console.log(`[${i}] ${entry[1]}:`, entry[2]);
}
});
// Expected output:
// [0] default: { ad_storage: "denied", analytics_storage: "denied", ... }
// [5] update: { ad_storage: "granted", analytics_storage: "granted", ... } GTM debugging
- Enable GTM Preview mode (in the GTM interface, click “Preview”)
- Visit your site — the GTM debug panel appears at the bottom
- Interact with the consent banner
- In the debug panel, look for the
cookieboss_consent_updateevent - Click it to see the dataLayer payload and which tags fired
Reset everything
To start with a clean slate for testing:
javascript
// Clear all CookieBoss data
document.cookie = 'cookieboss_consent=; path=/; max-age=0';
localStorage.removeItem('cookieboss_consent');
localStorage.removeItem('cookieboss_geo');
localStorage.removeItem('cookieboss_vid');
// Reload
location.reload(); This clears:
- The consent cookie
- The localStorage consent backup
- The geo detection cache
- The anonymous visitor ID