PHPackages                             martinschenk/livewire-cookie-consent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. martinschenk/livewire-cookie-consent

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

martinschenk/livewire-cookie-consent
====================================

livewire cookie consent modals with laravel livewire

v1.0.7(3y ago)263462MITPHPPHP ^8.0CI passing

Since Dec 20Pushed 11mo ago2 watchersCompare

[ Source](https://github.com/martinschenk/livewire-cookie-consent)[ Packagist](https://packagist.org/packages/martinschenk/livewire-cookie-consent)[ Docs](https://github.com/martinschenk/livewire-cookie-consent)[ RSS](/packages/martinschenk-livewire-cookie-consent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (12)Used By (0)

⚠️ Maintenance Notice
---------------------

[](#️-maintenance-notice)

**This package is no longer actively maintained.** This package was built for Laravel 9/10 with Jetstream and Livewire v2 (created in late 2022). While it may continue to work with current Laravel/Livewire versions, I'm not providing regular updates or bug fixes. Feel free to fork the repository if you need ongoing maintenance or want to contribute improvements.

**👆 Consider upgrading to the [new lightweight Laravel Cookie Consent Plugin](https://github.com/martinschenk/laravel-cookie-consent) instead!**

🆕 **Alternative: Simple GDPR Cookie Consent Available!**
========================================================

[](#-alternative-simple-gdpr-cookie-consent-available)

**🚀 [Try the lightweight Laravel Cookie Consent Plugin](https://github.com/martinschenk/laravel-cookie-consent)**

Looking for something simpler? This alternative plugin offers:

- ✅ **Framework-independent** - no Laravel or JavaScript framework dependencies
- ✅ **Ultra-lightweight** - minimal footprint, maximum performance
- ✅ **GDPR-compliant out-of-the-box** - automatically blocks Google Analytics until consent
- ✅ **Dead simple setup** - just add your Google Analytics ID and you're done
- ✅ **User-friendly modals** - clean, responsive consent interface
- ✅ **Persistent user control** - footer link allows users to change preferences anytime

**Perfect for projects that need** straightforward cookie consent without complex dependencies or extensive configuration. Ideal if you want to get GDPR compliance up and running in minutes.

---

Laravel Livewire Cookie-Consent Modal
=====================================

[](#laravel-livewire-cookie-consent-modal)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3d644fc8a73314ab0f7c277a7bc0d5809f3d15d9613304ed48118a239b80c8dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617274696e736368656e6b2f6c697665776972652d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/martinschenk/livewire-cookie-consent)[![Total Downloads](https://camo.githubusercontent.com/d4f53055fc77dd1c12c8515837a81f50267eabff920b00fd3d61a92702b33063/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617274696e736368656e6b2f6c697665776972652d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/martinschenk/livewire-cookie-consent)

With [this package](https://github.com/martinschenk/livewire-cookie-consent) there will be set no (Google Marketing &amp; Analytics) Cookies on your website, until the user has accepted the Cookie Policy. (Except essential and funtionality cookies). All of this, because of the crazy EU Cookie Law.

[![Modal cookie consent](docs/img/livewire-cookie-consent-modal1.jpg "Modal 1 for Cookie consent")](docs/img/livewire-cookie-consent-modal1.jpg)[![Preferences Modal](docs/img/livewire-cookie-consent-modal2.jpg "Modal 2 preferences for cookie consent")](docs/img/livewire-cookie-consent-modal2.jpg)

Livewire Cookie Consent is a Livewire component that provides Opt-In Cookie Modals. The user can choose between

- Essential and functional cookies
- Analytical cookies
- Marketing cookies

Special:

- No Analytical or Marketing cookies are set before the Opt-In decision of the user (European laws).
- User can open the modal with link in page-footer to reconfigure his cookie consent selections.
- You can connect this component to Google Tag Manager if you want to. GTM example Script is included.
- You can add in your Google Tag Manager triggers for every other Cookie, you wish to control.

Requirements
------------

[](#requirements)

- Laravel 9/10
- Laravel Jetstream with Livewire v2
- PHP 8.0+

Jetstream should only be installed into new Laravel applications. Attempting to install Jetstream into an existing Laravel application will result in unexpected behavior and issues

Installation
------------

[](#installation)

### If you haven't installed Jetstream and Livewire

[](#if-you-havent-installed-jetstream-and-livewire)

```
composer require laravel/jetstream

php artisan jetstream:install livewire
```

### And now install the package

[](#and-now-install-the-package)

```
composer require martinschenk/livewire-cookie-consent
```

Register the package in /config/app.php

```
return [
    /*
     * Application Service Providers...
     */

    App\Providers\AppServiceProvider::class,
    ...
    Martinschenk\LivewireCookieConsent\CookieConsentModalServiceProvider::class,

];
```

Finalizing The Installation
---------------------------

[](#finalizing-the-installation)

After installing Jetstream, you should install and build your NPM dependencies and migrate your database:

```
npm install
npm run build
php artisan migrate
```

Include Livewire and vite directives
------------------------------------

[](#include-livewire-and-vite-directives)

Include this into your welcome.blade.php, landing page or any other base template you use.

```

    ...
    @livewireStyles
    @vite(['resources/css/app.css', 'resources/js/app.js'])

    ...
    @livewireScripts
    @livewire('livewire-ui-modal')
    @include('livewire-cookie-consent::cookieconsent')

```

Include link
------------

[](#include-link)

Normaly in the footer of your web-page, include this link. It will open the cookie modal to change preferences.

```

        {{ __('Cookie Config') }}

```

Publish the views and logo
--------------------------

[](#publish-the-views-and-logo)

The design is done with Tailwind. You can edit and adapt the files. You will find the views in resources/views/vendor/livewire-cookie-consent

```
php artisan vendor:publish --provider="Martinschenk\LivewireCookieConsent\CookieConsentModalServiceProvider" --tag="views"
```

Now it should work
------------------

[](#now-it-should-work)

Do just

```
   php artisan optimize:clear
   npm run dev
```

and you should see popup the modal if you reload your webpage.

Publish the rest if you want to
-------------------------------

[](#publish-the-rest-if-you-want-to)

### Dialog texts and languages

[](#dialog-texts-and-languages)

If you want to modify the text shown in the dialog you can publish the lang-files with this command:

```
php artisan vendor:publish --provider="Martinschenk\LivewireCookieConsent\CookieConsentModalServiceProvider" --tag="lang"
```

This will publish the f.e. english language file to lang/vendor/livewire-cookie-consent/en/texts.php .

```
return [
    'alert_accept' => 'Accept all cookies',
    'alert_essentials_only' => 'Accept only necessary cookies',
    'alert_settings' => 'Adjust your preferences',
    ...
];
```

### Config file

[](#config-file)

Be careful changing the config values, because the Google Tag Manager is using them. Only change them if you know what you do.

```
php artisan vendor:publish --provider="Martinschenk\LivewireCookieConsent\CookieConsentModalServiceProvider" --tag="config"
```

This is the content of the published config-file. You'll find it in /config/livewire-cookie-consent.php

```
return

    'cookie_name' => 'cookie-consent',

    'cookie_value_analytics' => '2',
    'cookie_value_marketing' => '3',
    'cookie_value_both' => 'true',
    'cookie_value_none' => 'false',

    'consent_cookie_lifetime' => 60 * 24 * 365,
    'refuse_cookie_lifetime' => 60 * 24 * 30,

];
```

Configure Google Tag Manager
----------------------------

[](#configure-google-tag-manager)

If you want to use Google Tag Manager, you will find an example Container script for configuration of GTM [here](./docs/GTM-Github_v16_livewire-cookie-consent.json)

[Example Container for GTM:](./docs/GTM-Github_v16_livewire-cookie-consent.json)

```
{
    "exportFormatVersion": 2,
    "exportTime": "2022-11-25 20:49:55",
    "containerVersion": {
        "path": "accounts/6060538801/containers/95560929/versions/16",
        "accountId": "6060538801",
        "containerId": "95560929",
        "containerVersionId": "16",
        "name": "cookie consent v1.0",
        "container": {
            "path": "accounts/6060538801/containers/95560929",
            "accountId": "6060538801",
            "containerId": "95560929",
            "name": "www.vissit.io",
            "publicId": "GTM-YOUR-CODE",

```

You can import or merge this GTM Container into your GTM account. Here you can find the [GTM Documentation](https://support.google.com/tagmanager/answer/6106997?hl=en-GB) for importing a Container. Its possible that you have to change the GTM-Code in the GTM Container to your own GTM-Code.

Once configured your Google Tag Manager, you have to insert the Google Tag Manager Code in the HEAD section of your website this way (between @livewireStyles and @vite...):

```
    @livewireStyles
    HERE THE GOOGLE TAG MANAGER CODE
    @vite(['resources/css/app.css', 'resources/js/app.js'])
```

Example:

```

    ...
    @livewireStyles

        window.dataLayer = window.dataLayer || [];

    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
            new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
        'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,'script','dataLayer','GTM-YOURKEY');

    @vite(['resources/css/app.css', 'resources/js/app.js'])

```

Replace GTM-YOURKEY with your Google Tag Manager Key.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

This package is based on the one from spatie:  and on statikbe:

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

8

Last Release

1201d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.0.1PHP ^7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d14dacfc77900b8475b356a4f2d0c4dbe672a82cfdd65e2597e71d4b01c9c72?d=identicon)[Martin Schenk](/maintainers/Martin%20Schenk)

---

Top Contributors

[![martinschenk](https://avatars.githubusercontent.com/u/635827?v=4)](https://github.com/martinschenk "martinschenk (72 commits)")

---

Tags

laravellivewirecookiemodalcookie-consentconsent

### Embed Badge

![Health badge](/badges/martinschenk-livewire-cookie-consent/health.svg)

```
[![Health](https://phpackages.com/badges/martinschenk-livewire-cookie-consent/health.svg)](https://phpackages.com/packages/martinschenk-livewire-cookie-consent)
```

###  Alternatives

[wire-elements/modal

Laravel Livewire modal component

1.2k3.8M31](/packages/wire-elements-modal)[livewire/flux

The official UI component library for Livewire.

9385.0M85](/packages/livewire-flux)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[statikbe/laravel-cookie-consent

Cookie consent modal for EU

213396.7k](/packages/statikbe-laravel-cookie-consent)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)[marcorieser/statamic-livewire

A Laravel Livewire integration for Statamic.

2381.5k10](/packages/marcorieser-statamic-livewire)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
