On this page
Before you start
A Content Security Policy (CSP) is a header that tells browsers which addresses your website may load from. You only need this article if your website sends one. Signs that your policy blocks CookieScan:
- the banner doesn't appear, or appears without its styles
- the banner's buttons don't respond
- your browser's console shows messages about a Content Security Policy that name
cookiescan.com
You need access to wherever your website sets its policy, such as your web server, hosting settings or a security plugin.
Add CookieScan's addresses
Your cookie banner loads from two addresses: https://banner.cookiescan.com and https://cdn.cookiescan.com. Add them to these directives, alongside the sources you already allow.
| Directive | Add | What it allows |
|---|---|---|
| script-src | https://banner.cookiescan.com https://cdn.cookiescan.com | The CookieScan script and the banner's own script |
| style-src | https://cdn.cookiescan.com | The banner's stylesheet and font styles |
| font-src | https://cdn.cookiescan.com | The banner's font |
| img-src | https://cdn.cookiescan.com | The banner's images, such as the CookieScan logo |
| connect-src | https://banner.cookiescan.com https://cdn.cookiescan.com | Loading the banner's content and saving each visitor's choice |
| style-src-attr | 'unsafe-inline' | The inline style attributes that keep parts of the banner hidden |
For example, a policy that allows only your own website and CookieScan looks like this:
script-src 'self' https://banner.cookiescan.com https://cdn.cookiescan.com;
style-src 'self' https://cdn.cookiescan.com;
style-src-attr 'unsafe-inline';
font-src 'self' https://cdn.cookiescan.com;
img-src 'self' https://cdn.cookiescan.com;
connect-src 'self' https://banner.cookiescan.com https://cdn.cookiescan.comInline styles
The banner applies its colours without an inline style element, so style-src doesn't need 'unsafe-inline' for them. In older browsers, such as Safari before version 16.4, the banner falls back to an inline style element. Your policy blocks that unless it allows 'unsafe-inline', and the banner then shows its default colours.
The banner also keeps some of its parts hidden with inline style attributes, such as its preferences panel. Allow them with style-src-attr 'unsafe-inline'. Without it, the preferences panel can show as soon as the page loads.
Nonces
If your policy allows scripts by nonce, add your nonce to the CookieScan script tag. If it also uses 'strict-dynamic', the banner's own script is then allowed too, because the CookieScan script loads it.
Check it worked
Open your website in a private browser window, with your browser's console open. Your cookie banner appears with its colours and font, and its buttons work. The console shows no Content Security Policy messages that name cookiescan.com. Make a choice, then check that the Dashboard shows Receiving consents.