PHPackages                             itemvirtual/cookies-popup - 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. itemvirtual/cookies-popup

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

itemvirtual/cookies-popup
=========================

Cookie consent management for Laravel projects

1.2.7(1mo ago)22811MITPHPPHP ^7.4 || ^8.0

Since Oct 23Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/itemvirtual/cookies-popup)[ Packagist](https://packagist.org/packages/itemvirtual/cookies-popup)[ Docs](https://github.com/itemvirtual/cookies-popup)[ RSS](/packages/itemvirtual-cookies-popup/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (28)Used By (0)

Cookies popup
=============

[](#cookies-popup)

> Laravel package

This package provides a popup layer to manage cookies consent

[![Latest Version on Packagist](https://camo.githubusercontent.com/33aa0f6dbb60509d4efe3257c6c2a29b20a7b1e7e3fc29908ce2af96e8eb831f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974656d7669727475616c2f636f6f6b6965732d706f7075702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itemvirtual/cookies-popup)[![Total Downloads](https://camo.githubusercontent.com/b03425c4a16244aa1482ca1d02b5dbc4283e47bd19e0541bd854fa3ba2bdef0c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6974656d7669727475616c2f636f6f6b6965732d706f7075702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itemvirtual/cookies-popup)

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

[](#installation)

You can install the package via composer:

```
composer require itemvirtual/cookies-popup
```

Publish config file (with --force option to update)

```
php artisan vendor:publish --provider="Itemvirtual\CookiesPopup\CookiesPopupServiceProvider" --tag=config
```

You need to add package cookies name to the `EncryptCookies` except array

```
# file app/Http/Middleware/EncryptCookies.php
protected $except = [
    'analytical_cookies',
    'advertising_cookies',
    'recaptcha_cookies',
    'preferences_cookies',
];
```

In laravel 11 you should add the cookies name to the `encryptCookies` method in your application's `bootstrap/app.php` file

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->encryptCookies(except: [
        'analytical_cookies',
        'advertising_cookies',
        'recaptcha_cookies',
        'preferences_cookies',
    ]);
})
```

### Generate translations

[](#generate-translations)

There is a command to create the required translations in `labels` section

```
php artisan cookies-popup:generate-labels
```

If you prefer to create the translations in a file, these are the necessary indexes

```
cookies-popup-title
cookies-popup-text
cookies-popup-configure
cookies-popup-accept
accept-required-cookies-label
accept-required-cookies-info
accept-preferences-cookies-label
accept-preferences-cookies-info
accept-analytical-cookies-label
accept-analytical-cookies-info
accept-advertising-cookies-label
accept-advertising-cookies-info
accept-recaptcha-cookies-label
accept-recaptcha-cookies-info
cookies-popup-close
cookies-configure-link
```

Usage
-----

[](#usage)

#### Print popup

[](#print-popup)

To add cookie popup, put this code after footer in your html layout

```
{!! \Itemvirtual\CookiesPopup\CookiesPopup::addCookiesPopup() !!}

```

If you set `add-inline-styles` to `false` in your `config/cookies-popup.php`. You should use `getHeadStyles()` inside your `` html tag

```
{!! \Itemvirtual\CookiesPopup\CookiesPopup::getHeadStyles() !!}

```

To add a link to open the cookie popup, use the id `cookies-popup-show` parameter

```
{{ trans('cookies-popup.cookies-configure-link') }}
```

#### Check if cookies are allowed

[](#check-if-cookies-are-allowed)

To hide or show content related with the cookies consent, use the `allowed` methods

```
@if(\Itemvirtual\CookiesPopup\CookiesPopup::allowedAnalyticalCookies())
@endif

```

```
@if(\Itemvirtual\CookiesPopup\CookiesPopup::allowedAdvertisingCookies())
@endif

```

```
@if(\Itemvirtual\CookiesPopup\CookiesPopup::allowedRecaptchaCookies())
@endif

```

```
@if(\Itemvirtual\CookiesPopup\CookiesPopup::allowedPreferencesCookies())
@endif

```

#### Add Google Analytics scripts

[](#add-google-analytics-scripts)

To add the scripts in your layout (`gtag.js` or `analytics.js`), use the method you need ()

```
{!! \Itemvirtual\CookiesPopup\CookiesPopup::getGtagJs() !!}

```

```
{!! \Itemvirtual\CookiesPopup\CookiesPopup::getAnalyticsJs() !!}

```

You need to add an env variable `GA_MEASUREMENT_ID` it can be a comma separated array

```
GA_MEASUREMENT_ID="UA-XXXXXXXX-X"
GA_MEASUREMENT_ID="G-XXXXXXXXXX, AW-XXXXXXXXXX"
```

The `analytics.js` script can be normal or `async` script [more info](https://developers.google.com/analytics/devguides/collection/analyticsjs#alternative_async_tag)

[analytics.js](https://developers.google.com/analytics/devguides/collection/analyticsjs)
[Universal Analytics (gtag.js)](https://developers.google.com/analytics/devguides/collection/gtagjs)

### Styling

[](#styling)

To styling your pop-up window, you have two options.
The `custom_styles` or `custom_classes` config parameters.

With `custom_styles` you can change some CSS styles. If you need a deeper design change, use `custom_classes`, which will concatenate your class to the generic one

### Documentation links

[](#documentation-links)

Google Consent Mode

[Cómo configurar el modo de consentimiento en sitios web](https://developers.google.com/tag-platform/security/guides/consent)
[Cómo solucionar problemas del modo de consentimiento con Tag Assistant](https://developers.google.com/tag-platform/security/guides/consent-debugging)
[Tag Manager consent mode support](https://support.google.com/tagmanager/answer/10718549)
[Google Tag Assistant](https://tagassistant.google.com)

### Google Consent Mode

[](#google-consent-mode)

Consent ModeCategoríaDescripciónad\_storagePublicitariasEs para almacenamiento relacionado con publicidad.ad\_user\_dataPublicitariasRecoge datos del usuario para personalización de anuncios.ad\_personalizationPublicitariasControla si los anuncios se personalizan.analytics\_storageAnalíticasPara el uso de herramientas como Google Analytics.functionality\_storageFuncionalesAlmacena configuraciones relacionadas con la funcionalidad del sitio.personalization\_storageFuncionalesRelacionado con la personalización no publicitaria.security\_storageNecesariasPara almacenamiento relacionado con seguridad y prevención de fraude.### Function not defined

[](#function-not-defined)

If you don't add the analytics code `getGtagJs()` or `getAnalyticsJs()` and you get the message `Uncaught ReferenceError: setAnalyticalConsent/setAdvertisingConsent is not defined`, you'll need to add this script.

```

    if (typeof setAnalyticalConsent === "undefined") {
    function setAnalyticalConsent(value) {}
}
    if (typeof setAdvertisingConsent === "undefined") {
    function setAdvertisingConsent(value) {}
}

```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Sergio](https://github.com/sergio-item)
- [Itemvirtual](https://github.com/itemvirtual)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance93

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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 ~64 days

Recently: every ~172 days

Total

27

Last Release

36d ago

PHP version history (2 changes)1.0.0PHP ^7.4|^8.0

1.2.5PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c661af43bac4f574cfa73cee0f459791d0c789ffb21d6d27f1066f14b019d0c1?d=identicon)[itemvirtual](/maintainers/itemvirtual)

---

Top Contributors

[![sergio-item](https://avatars.githubusercontent.com/u/10372524?v=4)](https://github.com/sergio-item "sergio-item (32 commits)")

---

Tags

itemvirtualcookies-popup

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/itemvirtual-cookies-popup/health.svg)

```
[![Health](https://phpackages.com/badges/itemvirtual-cookies-popup/health.svg)](https://phpackages.com/packages/itemvirtual-cookies-popup)
```

###  Alternatives

[dantleech/fink

Checks Links

2266.5k2](/packages/dantleech-fink)[maantje/pulse-php-fpm

A Laravel Pulse card to show php-fpm status

46142.1k](/packages/maantje-pulse-php-fpm)[bitrix-expert/bbc-module

Module with classes for the basis components

1952.0k1](/packages/bitrix-expert-bbc-module)

PHPackages © 2026

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