tv2regionerne / statamic-cookiebot
Requires
- statamic/cms: ^4.0
Requires (Dev)
- laravel/pint: ^1.13
- mockery/mockery: ^1.3.1
- nunomaduro/collision: ^6.0 || ^7.0
- orchestra/testbench: ^7.0 || ^8.0
- pestphp/pest: ^2.24
- phpunit/phpunit: ^9.0 || ^10.0
This package is auto-updated.
Last update: 2024-11-19 16:43:26 UTC
README
Statamic Cookiebot is a Statamic addon that integrates with CookieBot.
Features
Please see the cookiebot documentation for the js properties, methods and events https://www.cookiebot.com/da/developer/
How to Install
You can search for this addon in the Tools > Addons
section of the Statamic control panel and click install, or run the following command from your project root:
composer require tv2regionerne/statamic-cookiebot
Set the ENV COOKIEBOT_ID with the Domain Group ID.
This is found in your cookiebot account under Your Scripts section.
COOKIEBOT_ID=4cdc3711-42e3-45f8-8143-70964c23343c
You may publish the config and overwrite the attributes of the tag.
See the config/statamic-cookiebot.php
files.
php artisan vendor:publish --tag=statamic-cookiebot-config
How to Use
Add this antlers tag to the header of your template to add the cookiebot js code.
<head> {{ cookiebot:scripts }} </head>
The tag will output a html tag like this if the COOKIEBOT_ID
env has been configured.
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="00000000-0000-0000-0000-000000000000">
Client side
A javascript API is available directly from Cookiebot.
See the js documentation at https://www.cookiebot.com/en/developer/
Server side
For server side checking of consent, use one of the below tags.
The tags will return a boolean.
{{ cookiebot:necessary }} {{ cookiebot:preferences }} {{ cookiebot:statistics }} {{ cookiebot:marketing }} {{ cookiebot:all }}
To wrap some code use it like this.
Check for consent on necessary
.
{{ if {cookiebot:necessary} }} // code when consent is given {{ else }} // code when no consent is given {{ /if }}
Tag options are: