A package to integrate Cookiebot into Neos.
Benjamin Kentsch - [email protected]
Michael Gerdemann - [email protected]
Enes Erk - [email protected]
The development and the public-releases of this package is generously sponsored by our employer https://www.avency.de.
composer require avency/neos-cookiebot
Configure the key in Settings.yaml:
Avency:
Neos:
CookieBot:
key: ''
Or add the mixin to your root page:
superTypes:
'Avency.Neos.CookieBot:Mixin.CookieBotKey': true
By default, Cookiebot only rewrites the type of <script> tags. With the following helper script, you can also prevent the loading any (external) resources (e.g., scripts and styles) until the appropriate consent is given. After consent, the tags are automatically "unblocked".
Import the script once in your project:
import 'Packages/Plugins/Avency.Neos.CookieBot/Resources/Private/Assets/JavaScript/loadScripts';For resources that should be blocked, repklace the attributes with the corresponding data-attributes and set type to text/plain. Set the required consent category via data-cookieconsent (e.g., "marketing").
<script
type="text/plain"
data-cookieblock-type="text/javascript"
data-cookieblock-src="https://example.com/script.js"
data-cookieconsent="marketing"
/>Result after consent: Once consent for the specified category is granted, the tags are automatically rewritten into loadable resources:
<script
type="text/javascript"
src="https://example.com/script.js"
data-cookieconsent="marketing"
/><link
rel="stylesheet"
type="text/plain"
data-cookieblock-type="text/css"
data-cookieblock-href="https://example.com/styles.css"
data-cookieconsent="marketing"
/>Result after consent: Once consent for the specified category is granted, the tags are automatically rewritten into loadable resources:
<link
rel="stylesheet"
type="text/css"
href="https://example.com/styles.css"
data-cookieconsent="marketing"
/>data-cookieconsentdefines the required consent category (e.g., "marketing"). You can specify multiple categories as a comma-separated list.data-cookieblock-srcanddata-cookieblock-hrefhold the blocked URL, which will be applied tosrcorhrefafter consent.data-cookieblock-typedefine the target MIME types that will be set after unblocking.- The initial
type="text/plain"prevents execution or loading before consent.
The MIT License (MIT). Please see License File for more information.