Option 1: Domain-based CSP (without nonce)
If you’re using domain-based CSP, add the CookieChimp domains to your policy. This is the simplest approach and works well for most websites.Content-Security-Policy header.
Option 2: Nonce-based CSP
If you’re using nonce-based CSP for stricter security, add anonce attribute to the CookieChimp script tag. CookieChimp will automatically detect the nonce and apply it to all dynamically created CSS and JavaScript elements.
What each directive allows
| Directive | Purpose |
|---|---|
script-src | Allows the CookieChimp widget script and its dependencies |
style-src | Allows consent banner and modal stylesheets |
connect-src | Allows API requests to log consent and fetch configuration and translations |
frame-src | Allows rendering the preferences modal and embedding the privacy portal vendor list |
Additional domains for integrations
If you’re using CookieChimp alongside third-party integrations, you may need to add their domains to your CSP as well. Some common examples:| Integration | Directive | Domain |
|---|---|---|
| Meta Pixel | script-src | https://connect.facebook.net |
| Google Analytics | script-src | https://*.googletagmanager.com https://*.google-analytics.com |
| Google Tag Manager | script-src | https://*.googletagmanager.com |
These additional domains are not specific to CookieChimp — they are required by the third-party services themselves. Only add the domains for services you actually use.
Testing your CSP configuration
After updating your CSP header, verify everything works correctly:- Open your website and check that the CookieChimp banner appears.
- Open the browser developer tools (F12) and check the Console tab for any CSP violation errors. They typically look like:
Refused to load the script ... because it violates the following Content Security Policy directive. - Test the full consent flow — accept, reject, and update preferences — to ensure all API calls succeed.
If you see CSP violations in the console related to CookieChimp, double-check that all the required domains listed above are included in the correct directives.