This integration allows your GTM Consent Mode Inspector Chrome extension to detect and respond to Cookiebot consent changes on the Premium Carpets Co website.
When users accept or reject cookies on the Premium Carpets Co website, your Chrome extension will:
- Detect the consent change in real-time
- Show a visual notification
- Update the extension's state
- Trigger GTM events for tracking
- Provide detailed consent information
- Chrome Extension: Your GTM Consent Mode Inspector extension must be installed and active
- Target Website: Access to https://vermillion-zuccutto-ed1811.netlify.app/
- Browser Console: Ability to open developer tools (F12)
- Navigate to the website: Go to https://vermillion-zuccutto-ed1811.netlify.app/
- Open Developer Tools: Press F12 or right-click → Inspect
- Go to Console tab: Click on the "Console" tab
- Copy the integration script: Copy the script from
website-integration.js - Paste and execute: Paste the script into the console and press Enter
- Test the integration: Interact with the Cookiebot banner
- Create a bookmark: Right-click your bookmarks bar → Add page
- Name it: "Premium Carpets Integration"
- Set the URL: Copy the entire line from
bookmarklet.js - Use it: Click the bookmark when on the Premium Carpets Co website
- Open the integration page: Open
premium-carpets-integration.htmlin your browser - Copy the script: Click the "Copy Script" button
- Navigate to the website: Go to the Premium Carpets Co website
- Paste in console: Open console (F12) and paste the script
The integration uses multiple methods to detect your Chrome extension:
- Content Script Detection: Checks for
window.gtmInspectorContentLoaded - Injected Script Detection: Checks for
window.ConsentInspector - Runtime Communication: Attempts to send messages to the extension
The integration monitors Cookiebot consent changes through:
- Event Listeners: Listens for Cookiebot events (
CookiebotOnAccept,CookiebotOnDecline, etc.) - Polling: Checks consent state every 2 seconds
- DataLayer Monitoring: Watches for consent-related GTM events
When consent changes are detected:
- Visual Indicator: Shows a notification on the website
- Extension Notification: Sends data to your Chrome extension
- GTM Events: Updates the dataLayer with consent change events
- Console Logging: Provides detailed logs for debugging
- ✅ Green notification appears on the website
- 🍪 Chrome extension shows a notification
- 📊 GTM events are triggered
- 🔍 Console shows detailed logs
- ❌ Red notification appears on the website
- 🍪 Chrome extension shows a notification
- 📊 GTM events are triggered
- 🔍 Console shows detailed logs
// Key functions in the integration script:
- detectChromeExtension() // Detects if your extension is active
- triggerExtensionNotification() // Sends data to your extension
- handleConsentChange() // Processes consent changes
- showConsentIndicator() // Shows visual feedback
- setupCookiebotListeners() // Sets up event listeners
- startConsentMonitoring() // Starts polling for changes- PostMessage:
window.postMessage()for cross-context communication - Custom Events:
CustomEventfor DOM-based communication - Runtime Messages:
chrome.runtime.sendMessage()for extension communication - DataLayer: GTM dataLayer updates for tracking
// Consent change notification data:
{
website: "Premium Carpets Co",
url: "https://vermillion-zuccutto-ed1811.netlify.app/",
action: "accept" | "decline" | "update" | "monitor",
consent: {
analytics: boolean,
advertising: boolean,
functionality: boolean,
personalization: boolean,
necessary: boolean
},
timestamp: number,
changeCount: number
}The integration provides detailed console logs:
[Premium Carpets Co] [10:30:15] Initializing Premium Carpets Co Cookiebot integration...
[Premium Carpets Co] [10:30:16] Cookiebot loaded
[Premium Carpets Co] [10:30:16] Chrome extension detected via content script
[Premium Carpets Co] [10:30:17] Cookiebot accept event fired
[Premium Carpets Co] [10:30:17] Consent state updated (change #1):
[Premium Carpets Co] [10:30:17] Analytics: true, Advertising: true, Functionality: true, Personalization: true
[Premium Carpets Co] [10:30:17] Triggering extension notification for: accept
Once the integration is loaded, you can test it in the console:
// Check integration status
window.PremiumCarpetsCookiebotIntegration.getConsentState()
// Check if extension is detected
window.PremiumCarpetsCookiebotIntegration.getExtensionDetected()
// Manually trigger a notification
window.PremiumCarpetsCookiebotIntegration.triggerNotification('test')
// View logs
window.PremiumCarpetsCookiebotIntegration.log('Test message', 'info')- Check if extension is active: Look for the extension icon in your browser
- Refresh the page: Sometimes the extension needs a page refresh
- Check console for errors: Look for any error messages
- Verify permissions: Ensure the extension has access to the website
- Check if Cookiebot is loaded: Look for
window.Cookiebotin console - Verify event listeners: Check if Cookiebot events are firing
- Test manually: Try manually changing consent in console
- Check for conflicts: Look for other scripts that might interfere
- Check z-index: Ensure no other elements are covering the notification
- Verify CSS: Check if styles are being applied correctly
- Browser compatibility: Test in different browsers
- Ad blockers: Disable ad blockers that might interfere
You can modify the integration script to customize behavior:
const CONFIG = {
websiteName: 'Premium Carpets Co',
websiteUrl: 'https://vermillion-zuccutto-ed1811.netlify.app/',
extensionName: 'GTM Consent Mode Inspector',
debugMode: true, // Set to false to disable console logs
notificationDuration: 5000, // How long notifications show
pollingInterval: 2000 // How often to check for changes
};To use this integration with other websites:
- Update the configuration: Change
websiteNameandwebsiteUrl - Modify detection logic: Adjust for different CMP implementations
- Test thoroughly: Ensure compatibility with the target website
- Update event listeners: Modify for different CMP event names
If you encounter issues:
- Check the console logs for detailed error messages
- Verify the extension is working on other websites
- Test with the provided test page (
test-cookiebot.html) - Check browser compatibility and extension permissions
- Initial integration script
- Cookiebot event detection
- Chrome extension communication
- Visual notifications
- GTM dataLayer integration
- Comprehensive logging and debugging
Note: This integration is specifically designed for the Premium Carpets Co website with Cookiebot. For other websites or CMPs, modifications may be required.