Setup
/config/_default/params.yaml
cookie_banner:
enable: false # Enable Cookie banner
cookieconsent:
enable: false # Use CookieConsent
analytics: false
functionality: false
marketing: false
disablePageInteraction: false
consentModal:
layout: box
position: bottom left
preferencesModal:
layout: box
position: right
The analytics category loads Google Analytics and Matomo with cookies: true. The marketing category loads Meta Pixel. The other analytics services are cookieless and load without consent. See Analytics.
Your own scripts
CookieConsent runs any script marked with a category once the visitor accepts it. Add them to the script partial, rendered at the end of body.
/layouts/_partials/footer/scripts.html
<script type="text/plain" data-category="marketing" data-service="Example">
// Runs after consent to the marketing category
</script>
<script type="text/plain" data-category="marketing" data-service="Example" data-src="https://example.com/tag.js"></script>
data-categoryisanalytics,functionalityormarketing. Enable the matching category undercookieconsent, so visitors see it in the preferences modal.data-servicelists the script as a separate service in the preferences modal.data-srcreplacessrcfor an external script.
Unlike the analytics services, these scripts are rendered in every build. Wrap them in {{ if hugo.IsProduction }} to keep local builds out.
Documentation
A complete documentation of how to use CookieConsent.
See documentation