Migration Guide: Updating to New Cookienovo Script
We've improved our Cookienovo implementation to ensure full compliance with Google Consent Mode v2 and prevent cookies from being set before user consent. This guide will help you update from the old single-script format to the new two-part installation.
Why Update?
The old implementation could allow Google Analytics and other tracking services to set cookies before consent if those services loaded asynchronously. The new implementation uses an inline script to set consent defaults before any tracking services can load, ensuring full compliance with GDPR, ePrivacy Directive, and Google Consent Mode v2 requirements.
Old Implementation (Still Works)
If you're currently using the single-script format below, it still works but may not prevent cookies if Google tags load asynchronously:
<!-- Old single script (still works) -->
<script site-token="YOUR_TOKEN" src="https://cookienovo.com/assets/client.js"></script>
New Implementation (Recommended)
The new two-part installation ensures consent defaults are set before any Google tags can fire. It also supports the defer attribute for better performance:
Option A: Simple (use our pre-configured script)
<!-- Step 1: Set consent defaults (pre-configured) -->
<script src="https://cookienovo.com/assets/cmp.js"></script>
<!-- Step 2: Load banner (can use defer) -->
<script site-token="YOUR_TOKEN" src="https://cookienovo.com/assets/client.js" defer></script>
Option B: Custom (inline, ~300 bytes, full control)
<!-- Step 1: Set consent defaults (inline) -->
<script>
window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}
gtag('consent','default',{'ad_storage':'denied','ad_personalization':'denied','ad_user_data':'denied','analytics_storage':'denied','functionality_storage':'denied','personalization_storage':'denied','security_storage':'granted','wait_for_update':500});
gtag('set','ads_data_redaction',true);
</script>
<!-- Step 2: Load banner (can use defer) -->
<script site-token="YOUR_TOKEN" src="https://cookienovo.com/assets/client.js" defer></script>
Migration Steps
<head> section.
site-token attribute unchanged.
window.cookienovoDebug.testConsentModeImplementation()
Important Notes
defer for better page load performance.
Verification
After updating your script tags, verify the implementation is working correctly:
// Open browser console and run:
window.cookienovoDebug.testConsentModeImplementation()
For Google Tag Manager Users
If you're loading Cookienovo via Google Tag Manager, use the GTM-specific script format that includes the inline consent defaults:
<!-- Step 1: Set consent defaults -->
<script>
window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}
gtag('consent','default',{'ad_storage':'denied','ad_personalization':'denied','ad_user_data':'denied','analytics_storage':'denied','functionality_storage':'denied','personalization_storage':'denied','security_storage':'granted','wait_for_update':500});
gtag('set','ads_data_redaction',true);
</script>
<!-- Step 2: Load banner via GTM -->
<script>
var script = document.createElement('script');
script.setAttribute('site-token', 'YOUR_TOKEN');
script.setAttribute('src', 'https://cookienovo.com/assets/client.js');
script.setAttribute('injected', 'true');
script.setAttribute('defer', 'true');
document.getElementsByTagName('head')[0].appendChild(script);
</script>
Benefits of Updating
defer attribute on main script for faster page loads without compromising compliance.
Need Help?
If you need assistance with the migration, please contact our support team. We're here to help ensure your implementation is fully compliant and working correctly.