cookieConsent()->isEnabled():?>
cookieConsent()->isCategoryAccepted('essential')):?>
Essential category is accepted (as it should be)!
cookieConsent()->isServiceAllowed('matomo')):?>
Matomo service is allowed!
You can also check consent in JavaScript:
if (VuFind.cookie.isCategoryAccepted('essential')) { ... }
if (VuFind.cookie.isServiceAllowed('matomo')) { ... }
==== JavaScript Events ====
The following events are emitted:
^ Event ^ Description ^
| vf-cookie-consent-first-done | User has given first consent |
| vf-cookie-consent-done | User has given consent or the page has been loaded with a stored consent |
| vf-cookie-consent-changed | User has changed their consent |
| vf-cookie-consent-initialized | Cookie consent service has been initialized |
===== Sample Configurations =====
VuFind comes with cookie consent category configuration for the built-in cookies and Matomo. The following sample configurations can be added to CookieConsent.yaml (typically in local/config/vufind directory) for additional services. The samples only include the relevant parts for the service, so merge them with the full configuration as required.
Since these are third-party services, you will need to verify that the sample configurations are up to date and suitable for the region.
Note that the sample configuration have all the texts in English. The texts can be replaced with translation strings for multi-language support.
==== YouTube ====
:!: At least expiration times may differ depending on region.
The following template and configuration allow you to display videos based on user consent. If the user has allowed the cookies for the category, videos are displayed. If not, the user gets a message and a link instead.
Template example:
plugin('cookieConsent'); ?>
isEnabled() || $cookieConsent->isCategoryAccepted('video')): ?>
The video cannot be displayed due to missing cookie consent.
Check Cookie Settings to make changes.
You can also view the video on YouTube (external link).
CookieConsent.yaml:
CookieConsent:
Categories:
video:
Title: Cookies for embedded video
Description: Cookies set by video platforms when you view embedded media.
DefaultEnabled: false
Essential: false
Cookies:
- Name: yt-player-bandwidth
Domain: youtube.com
ThirdParty: true
Description: Used to estimate bandwidth.
Expiration: session
- Name: yt-player-headers-readable
Domain: youtube.com
ThirdParty: true
Description: Used to store user's preferences.
Expiration: session
- Name: GPS
Domain: youtube.com
ThirdParty: true
Description: Used to store user's location.
Expiration: session
- Name: VISITOR_INFO1_LIVE
Domain: youtube.com
ThirdParty: true
Description: Used to estimate bandwidth.
Expiration: 6
ExpirationUnit: months
- Name: PREF, __Secure-YEC
Domain: youtube.com
ThirdParty: true
Description: Used to store user's preferences.
Expiration: 8
ExpirationUnit: months
- Name: YSC, CONSENT, SOCS
Domain: youtube.com
ThirdParty: true
Description: Used to track user's actions for marketing purposes.
Expiration: 8
ExpirationUnit: months
AutoClearCookies:
- Name: '/^(yt-player-.*|GPS|VISITOR_INFO1_LIVE|PREF|__Secure-YEC|YSC|CONSENT|SOCS)$/'