emplify-software/statamic-cookie-dialog
A GDPR-compliant cookie consent dialog for Statamic. Visitors can accept or reject individual cookie groups, and scripts stay blocked until consent is given. Cookie groups and translations are configurable, making it easy to drop into any Antlers template.
composer require emplify-software/statamic-cookie-dialog. Statamic auto-discovers the addon service provider; no manual config/app.php registration needed.php artisan vendor:publish and select the package's config and view tags. You want two things on disk:
config/statamic/cookie-dialog.php — cookie name/lifetime, consent categories, default state, per-site overrides.resources/views/vendor/statamic-cookie-dialog/ — the dialog markup you'll actually restyle.</body> in resources/views/layout.antlers.html so every page gets the dialog without per-template work. Avoid putting it inside a page-level partial that some templates skip.Category-driven script gating. Model consent as categories (necessary, analytics, marketing) rather than a boolean. Gate scripts with a non-executing type and swap it on consent:
<script type="text/plain" data-consent="analytics" data-src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"></script>
document.addEventListener('cookie-dialog:accepted', (e) => {
const granted = e.detail?.categories ?? [];
document.querySelectorAll('script[data-consent]').forEach((el) => {
if (granted.includes(el.dataset.consent)) {
const s = document.createElement('script');
s.src = el.dataset.src;
s.async = true;
document.head.appendChild(s);
}
});
});
Check the addon's actual event name in the published JS before wiring this — the pattern is stable, the event string is not.
Multi-site (new in v3.0.4). This is the release that matters. Treat site context as a first-class input:
{{ site:handle }} / Site::current() when you need to vary the dialog's intro copy or links to a privacy policy that lives per-site.Consent before tags fire. If you use GTM or Google Consent Mode, set defaults to denied in <head> before the container loads, then call gtag('consent', 'update', …) from the addon's accept event. A dialog that renders the UI correctly but lets GTM fire on page load is the most common failure mode of packages like this.
Re-openable preferences. Cookie banners are not one-shot. Expose a footer link ("Cookie settings") that re-opens the dialog so users can withdraw consent — required under GDPR and an easy thing to forget.
Static caching. With Statamic's static cache enabled, the dialog HTML is baked into the page and the cookie is client-side only. That's fine, but: warm each site's URLs separately, and make sure any server-rendered "you have already consented" state isn't cached into the page for everyone.
.example.com), a consent granted on site A can read as granted on site B. Namespace the cookie per site handle, and decide explicitly whether that's what you want — for different jurisdictions it usually isn't.config:cache bites you. Statamic/Laravel config is cached in production. After editing cookie-dialog.php, run php artisan config:clear (or config:cache) or your override simply won't apply, and you'll spend an hour debugging the wrong layer.type="text/plain" only stops external script loading when the tag is created dynamically. Any already-inlined analytics snippet will run regardless — move it to the gated pattern.__() and you use full-page caching without site-aware cache keys, one site's language can be served to another. Confirm the static cache path includes the site/domain.^3.0 and test the upgrade on a multi-site install specifically — that's the code path that changed.How can I help you explore Laravel packages today?