Download the PHP package gridonic/statamic-consent-manager without Composer
On this page you can find all versions of the php package gridonic/statamic-consent-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gridonic/statamic-consent-manager
More information about gridonic/statamic-consent-manager
Files in gridonic/statamic-consent-manager
Package statamic-consent-manager
Short Description A Statamic 3 addon to manage consent for cookies.
License
Informations about the package statamic-consent-manager
Statamic Consent Manager
A Statamic 3 addon to manage consent for cookies 🍪.
Features
- Define consent groups and scripts loaded dynamically only when consent for a group is given.
- Provides a simple javascript API to read and change consent for users.
- Consent is stored client-side only, making it possible to use the static cache.
Installation
Run the following commands:
Configuration
Edit the configuration file located in config/statamic/consent_manager.php
:
Usage
- Define your consent groups and their scripts in the configuration.
- Add the
{{ consent_manager }}
tag in thehead
of your layout.
That's it! 🥳 What's left up to you is to design a nice cookie banner and modify consent data by using the javascript API.
Rendering a cookie banner
The addon provides the tag {{ consent_manager:groups }}
which can be used to loop over
consent groups in Antlers.
ℹ️ To read of modify consent, you need to use the javascript API, because the data is stored client-side only.
Javascript API
The addon exposes a window.consentManager
object to read and write consent data.
Method | Description |
---|---|
getConsent(group: string): boolean |
Check if the user has consented to a group. |
setConsent(group: string, consent: boolean) |
Set or remove consent to a group. If consent is given, all scripts of the group are appended to the DOM. |
isRequired(group: string): boolean |
Check if a group is required. |
getGroups(): Array |
Get all consent groups. |
getGroup(group: string): Object |
Get information about a single group. |