Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Statamic Consent Kit Laravel Package

quebecstudio-mods/statamic-consent-kit

A consent management addon for Statamic that adds GDPR-ready cookie banners and lets you gate tracking scripts, embeds, and analytics until visitors opt in. Manage consent preferences, log agreements, and stay compliant without leaving the control panel.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package with Composer, then publish its config, views, and frontend assets:

composer require <vendor>/<package>
php artisan vendor:publish --provider="<Vendor>\<Package>\<PackageServiceProvider>"

Check the published config first — this is where banner behavior lives. For most Laravel apps the key areas are:

  • Appearance — colors, positioning, full-width/sticky behavior, and the new reserveSpace option.
  • Categories / consent groups — which cookie categories are shown and how consent is stored.
  • Cookie settings — name, lifetime, domain, and SameSite behavior.

Then include the banner component in your main layout, typically just before </body>:

@include('cookie-consent::index')

Your first use case should be simple: render the banner, accept/reject once, reload the page, and confirm the banner stays hidden and the consent cookie is present. Once that works, wire one real integration — for example, conditionally loading analytics only when the relevant consent category is accepted.

Implementation Patterns

Put the banner in the root layout, not individual pages. Consent applies across the whole application, so include it once in layouts/app.blade.php or your equivalent.

Gate scripts on consent rather than loading them unconditionally. A common pattern is to render non-essential scripts only after the relevant category is accepted, or to expose a small helper/event that your own scripts listen to:

@if (app(\Vendor\Package\Consent::class)->has('analytics'))
    <script src="{{ asset('js/analytics.js') }}"></script>
@endif

For scripts that must be injected dynamically, listen for the package’s consent-updated event and initialize them client-side.

Use reserveSpace when the banner is full-width and sticky. In 6.1.0 this is an Appearance option, off by default. When enabled, the banner reserves its own height at the end of the page so it does not cover the footer, and that reserved space opens and closes with the banner. Enable it for full-width sticky banners; leave it off for compact corner banners where footer overlap is not a concern.

// config/cookie-consent.php
'appearance' => [
    'position' => 'bottom',
    'full_width' => true,
    'reserve_space' => true, // new in 6.1.0
],

Publish and override the views for branding. Rather than fighting the default markup with CSS, publish the views and adjust the Blade templates directly. Keep your overrides minimal so future package updates are easier to merge.

Model consent categories around actual cookies/scripts. Keep the config mapping close to the scripts you gate. If you add a new analytics or marketing tool, add or update the corresponding category and verify the server-side and client-side checks both use it.

Test consent states explicitly. Use browser privacy tools or a fresh private window to verify the first-visit banner, the accepted state, the rejected state, and a returning visitor whose consent cookie already exists. Clear the consent cookie between test runs.

Gotchas and Tips

  • reserveSpace is off by default. If you upgrade to 6.1.0 expecting the footer behavior to change automatically, it will not. Enable it explicitly under Appearance.
  • Only use reserveSpace for sticky/full-width banners. It adds height to the end of the page. On compact banners or non-sticky placements it can create unnecessary whitespace.
  • Check mobile and short pages. Reserved space interacts with fixed footers, mobile browser chrome, and pages with little content. Verify the footer is not double-spaced and that the banner does not cover content while animating.
  • Clear config cache after config changes. In Laravel, php artisan config:clear is frequently the fix when Appearance or category changes appear to have no effect.
  • Cookie domain and SameSite settings matter across subdomains. If consent does not persist between www and the root domain, or across subdomains, inspect the cookie configuration and the browser’s cookie storage.
  • Watch CSS stacking contexts. Sticky and fixed banners can be hidden behind headers, modals, or footers with high z-index. If the banner is invisible or clipped, check stacking contexts before changing package config.
  • Frontend assets must be republished after package upgrades. If styles or markup look stale after updating, republish assets and clear view caches.
  • Extension points: published Blade views for markup, config for categories and appearance, and consent events/helpers for gating scripts. Prefer these over modifying vendor files.
  • Debugging consent state: inspect the consent cookie directly, confirm its value matches the configured categories, and test server-side helpers separately from client-side behavior. A common failure is client-side gating working while server-side rendering still emits a script.

Upgrade note for 6.1.0: this is an additive, opt-in change. No breaking changes are indicated. Existing banners keep their current behavior until reserveSpace is enabled.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment