A lightweight, GDPR-compliant cookie consent system with minimal dependencies for Laravel 11
Perfect for Laravel applications that need a simple, effective, and legally compliant cookie consent solution without the bloat of external JavaScript frameworks.
Screenshot shows the cookie consent banner with developer tools open, confirming no Google Analytics cookies are loaded before user consent.
- Zero external dependencies - No Livewire, no Filament, no JS frameworks
- Alpine.js & Vanilla JS - Uses Alpine.js that comes with Laravel
- GDPR-compliant - Legally sound implementation with opt-in for all cookie types
- Multilingual - German, English, Spanish and Chinese included
- Google Analytics Integration - Dynamic loading and removal of GA scripts
- Locale Cookie Management - Stores language preferences only with consent
- Blade Components - Easy integration into existing Laravel applications
- Tailwind CSS - Elegant, customizable design (optional)
- Mobile-First - Fully responsive for all devices
- Laravel: Version 11.x required - Laravel Installation
- Tailwind CSS: Version 3.x recommended - Tailwind CSS for Laravel
- Alpine.js: Version 3.x recommended (included with Laravel 11) - Alpine.js Documentation
Laravel 11 includes Alpine.js by default, so no additional installation is needed for this dependency. Tailwind CSS is recommended but not strictly required - the component will still work with your own CSS, but you'll need to modify the published views to match your styling framework.
Use these commands to verify your installed versions:
This plugin provides a lightweight, GDPR-compliant cookie consent system for Laravel 11 - fully implemented with Blade, Alpine.js, and vanilla JavaScript. It works without Livewire, Inertia, or external dependencies.
The EU General Data Protection Regulation (GDPR) and similar privacy laws worldwide require explicit user consent before storing non-essential cookies. This package implements a fully compliant solution that:
- Blocks all non-essential cookies by default
- Provides clear opt-in choices for different cookie categories
- Allows users to change their preferences at any time
- Properly documents consent for compliance purposes
- The plugin blocks any connection to Google Analytics by default
- Only when a user explicitly consents to the "Analytics" category, the GA script (gtag.js) is dynamically inserted into the <head>
- Website owners only need to enter their Google Tag ID (G-XXXXXXXXXX) - no additional customization required
- When analytics consent is declined, the GA script is not loaded
- Additionally, the plugin attempts to delete all typical GA cookies, including:
- _ga, _gid, gat*
- __ga*, __gads
- Even if some cookies cannot be fully deleted for technical reasons (e.g., HttpOnly), no tracking will occur as the JavaScript is not loaded
Result: Google has no access to user interactions unless consent is given.
The plugin currently stores a single preference: the language setting (locale).
- The language is automatically read from the <html lang="..."> attribute
- When the user consents to the preferences category, a locale=xx cookie is set (e.g., locale=en), which Laravel can use for automatic language switching
- If consent is revoked, the locale cookie is deleted
| UI / Modals | Blade + Tailwind |
| Logic | Alpine.js (x-data) |
| Consent Storage | localStorage |
| Cookie Handling | JavaScript (document.cookie) |
| Language Detection | document.documentElement.lang |
| GA Activation | document.createElement('script') |
| GA Blocking | No script inclusion + Cookie deletion |
After publishing the package assets, you can configure the cookie consent system in config/cookie-consent.php:
You can modify the configuration values directly in the published configuration file:
Include the cookie consent component in your main layout file:
Here's how to integrate the cookie consent component in your Laravel layout:
Note: The cookie consent component should be placed before the closing </body> tag to ensure all other elements are loaded first. This provides the best user experience.
An important feature is the ability to reopen the cookie settings menu at any time. Here are different implementation options:
This package comes with translations for:
- English (en)
- German (de)
- Spanish (es)
- Chinese (Simplified) (zh_CN)
You can publish the language files to customize them:
The cookie consent component uses Tailwind CSS by default. You can publish the views to customize the appearance:
This plugin is the ideal solution for modern Laravel 11 projects that want to:
- Stay GDPR-compliant ✅
- Maintain maximum control ✅
- Avoid unnecessary external consent tools ✅
- Remain fully customizable and open-source ✅
Laravel cookie consent, GDPR cookie banner, Laravel 11 cookie solution, cookie consent manager, Laravel GDPR compliance, cookie opt-in system, Alpine.js cookie consent, privacy cookie banner, EU cookie law Laravel, cookie consent popup, minimal cookie notice, lightweight cookie consent, Laravel cookie management, cookie consent without JavaScript frameworks
Contributions are highly welcome and appreciated!
This project is open for contributions, and we would love for you to help make it better. Whether you want to fix a bug, add a new feature, improve the documentation, or just give feedback, your help is welcome.
Please see CONTRIBUTING.md for detailed guidelines on how to contribute to this project.
Looking for something to work on? Issues labeled with good first issue are a great way to start contributing.
We're planning to add the following features in future releases:
- Support for additional cookie categories
- More styling options and themes
- Additional analytics services integration
- Cookie expiration management
- Support for older Laravel versions
Feel free to pick up any of these tasks or suggest new ones!
If this package made your life a little easier,
you can buy me a coffee – or make my day by sending a little note:
📬 Send a postcard to:
Martin Schenk
Calle Hiruela 3, 5-7
28035 Madrid, Spain
Small gestures, big smiles. Danke! 💚
The MIT License (MIT). Please see License File for more information.
.png)




