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

Step 1: Locate your current Cookienovo script tag in your website's <head> section.
Step 2: Replace it with the new two-part script shown above. Make sure to keep your site-token attribute unchanged.
Step 3: Ensure both scripts are placed before any Google tags (Google Analytics, Google Tag Manager, Google Ads, etc.).
Step 4: Test your implementation using the browser console debug function: window.cookienovoDebug.testConsentModeImplementation()

Important Notes

βœ… Backward Compatible: The old script format still works, but updating is recommended for optimal compliance.
βœ… Performance: The inline script is only ~300 bytes and loads synchronously. The main banner script can use defer for better page load performance.
βœ… No Backend Changes: You only need to update the HTML script tags. No database or configuration changes required.

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

βœ… Full Compliance: Prevents cookies from being set before user consent, even with async-loaded Google tags.
βœ… Google Consent Mode v2: Includes all required parameters (ad_personalization, ad_user_data) for March 2024 compliance.
βœ… Better Performance: Use defer attribute on main script for faster page loads without compromising compliance.
βœ… Industry Standard: Follows the same approach as Cookiebot, CookieHub, and other leading consent management platforms.

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.