Debugging

Use these techniques to diagnose and fix issues with your CookieBoss integration.

Browser Console

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
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

  1. Open DevTools > Network tab
  2. Filter by consent.js
  3. Verify the script loads with status 200
  4. Check the Size column — if it says “disk cache” or “memory cache”, it’s a cached version

Analytics beacons

  1. Filter by a.cookieboss.io
  2. You should see POST requests when the visitor interacts with the banner
  3. If these fail, check your CSP configuration

Geo detection

  1. Filter by the geo endpoint (look for requests to a.cookieboss.io with a path containing “geo”)
  2. The response should contain { country: "XX", region: "YY" }

Elements Panel (Shadow DOM)

The consent banner renders inside a Shadow DOM. To inspect it:

  1. Open DevTools > Elements tab
  2. Find the <div id="cookieboss-container"> element
  3. Expand the #shadow-root (open) node
  4. 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(...).

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

  1. Enable GTM Preview mode (in the GTM interface, click “Preview”)
  2. Visit your site — the GTM debug panel appears at the bottom
  3. Interact with the consent banner
  4. In the debug panel, look for the cookieboss_consent_update event
  5. 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