A GDPR-compliant solution offering enterprise-grade compliance with fully customizable cookie banners for Laravel applications. Simplifies regulatory requirements while maintaining excellent user experience and complete customization capabilities.
composer require devrabiul/laravel-cookie-consent
php artisan vendor:publish --provider="Devrabiul\CookieConsent\CookieConsentServiceProvider"
Include these components in your Blade templates to activate the banner site-wide.
<body theme="dark">
<body dir="rtl">
Directly pass options to the scripts() helper to override global config.
# Global Toggle
COOKIE_CONSENT_ENABLED=true
COOKIE_CONSENT_PREFERENCES_ENABLED=true
# Category Toggles
COOKIE_CONSENT_ANALYTICS=true
COOKIE_CONSENT_MARKETING=true
COOKIE_CONSENT_PREFERENCES=true
Define these functions in your JS to trigger scripts only after consent is given.
function loadGoogleAnalytics() {
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'YOUR_GA_ID');
const script = document.createElement('script');
script.src = 'https://www.googletagmanager.com/gtag/js?id=YOUR_GA_ID';
script.async = true;
document.head.appendChild(script);
}
function loadFacebookPixel() {
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){
n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window,document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
fbq('track', 'PageView');
}
This package is designed to meet the requirements of the UK Information Commissioner’s Office (ICO) and the GDPR by:
<a onclick="showHideToggleCookiePreferencesModal()">Change Cookie Preferences</a>
Fork the repository and submit a pull request if you want to contribute.
Click the Install Now button & enjoy it just like an app.
Join the Community
Sign in with your preferred social account to share your feedback This ensures all contribution are verified