PHPackages                             elleracompany/craft-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. elleracompany/craft-cookie-consent

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

elleracompany/craft-cookie-consent
==================================

Craft Cookie Consent Plugin

5.0.4(1y ago)957.5k↓46.8%6[14 issues](https://github.com/elleracompany/craft-cookie-consent/issues)proprietaryPHP

Since May 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/elleracompany/craft-cookie-consent)[ Packagist](https://packagist.org/packages/elleracompany/craft-cookie-consent)[ RSS](/packages/elleracompany-craft-cookie-consent/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (43)Used By (0)

Craft Cookie Consent
====================

[](#craft-cookie-consent)

Ellera Cookie Consent Plugin

Install the plugin
------------------

[](#install-the-plugin)

You can install this plugin from the Plugin Store.

Create hook in your template
----------------------------

[](#create-hook-in-your-template)

To give you full control over where the plugin is rendering the consent template. The cookie banner should be the first thing in the DOM for keyboard and screen-reader users.

You need to add this line right after your start-body-tag in the relevant layout file(s):

`{% hook 'after-body-start' %}`

Activate the plugin for your site
---------------------------------

[](#activate-the-plugin-for-your-site)

Navigate to the plugin inside your Control Panel. If you have the correct permissions, it should be visible in the menu.

Go to "Site Settings" and add your cookies and cookie groups (We've added some basic ones for you already).

Toggle the "Activated" lightswitch and you're off!

Customize
---------

[](#customize)

### Using a custom template

[](#using-a-custom-template)

Update the template file under Site Settings to point to your template file. The path is rendered with `Craft::$app->view->renderTemplate()`.

### Using custom CSS and/or JS

[](#using-custom-css-andor-js)

You can turn off loading of assets in Site Settings if you have your own.

You can look in `vendor/elleracompany/craft-cookie-consent/src/resources` to see the functionality currently implemented by the plugin.

Check for user consent
----------------------

[](#check-for-user-consent)

You can use this function to manage cookie generation for your scripts

`{% if craft.cookieConsent.getConsent('slug') %}`

You can use it in SEOmatic by navigating to `admin/seomatic/tracking` and updating the script template.

Planned features
----------------

[](#planned-features)

- Project.yaml compatibility

Example using SEOmatic
----------------------

[](#example-using-seomatic)

You will need to bust the SEOmatic cache in your twig templates (not in the SEOmatic script field)

```
{# -- START Cache-bust seomatic -- #}
{% set scriptContainer = seomatic.script.container() %}
{% do scriptContainer.clearCache(true) %}
{# -- END Cache-bust seomatic -- #}

```

After that you can update the script field inside SEOmatic to something like this:

```
{% if trackingId.value is defined and trackingId.value %}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','{{ analyticsUrl.value }}','ga');
ga('create', '{{ trackingId.value |raw }}', 'auto'{% if linker.value %}, {allowLinker: true}{% endif %});
{% if ipAnonymization.value or craft.cookieConsent.getConsent('default-marketing') != true %}
ga('set', 'anonymizeIp', true);
{% endif %}
{% if displayFeatures.value and craft.cookieConsent.getConsent('default-marketing') %}
ga('require', 'displayfeatures');
{% endif %}
{% if ecommerce.value and craft.cookieConsent.getConsent('default-marketing') %}
ga('require', 'ecommerce');
{% endif %}
{% if enhancedEcommerce.value and craft.cookieConsent.getConsent('default-marketing') %}
ga('require', 'ec');
{% endif %}
{% if enhancedLinkAttribution.value and craft.cookieConsent.getConsent('default-marketing') %}
ga('require', 'linkid');
{% endif %}
{% if enhancedLinkAttribution.value and craft.cookieConsent.getConsent('default-marketing') %}
ga('require', 'linker');
{% endif %}
{% set pageView = (sendPageView.value and not craft.app.request.isLivePreview) %}
{% if pageView %}
ga('send', 'pageview');
{% endif %}
{% endif %}

```

Cleaning up old consents
------------------------

[](#cleaning-up-old-consents)

You can use a console command to clear out old consents from the database.

```
./craft cookie-consent/retention/clear
```

This command has three optional parameters:

ParameterAlternativeDefaultTypeDescription-d #--days #365IntegerSets number of days to keep records-s #--sid #nullIntegerPass a site ID to only clear consents from that site-s --handle nullStringPass a site handle to only clear consents from that site**note:** you can only pass *sid* or *handle* - not both. If a site is not specified, consents will be deleted from all sites.

Example: Delete all consents older than 2 years from site with ID 1

```
./craft cookie-consent/retention/clear -sid 1 -d 730
```

The window.ccc object
---------------------

[](#the-windowccc-object)

As of version 1.6.0, a new object window.ccc has been added to the default template.

This object contains key-value pairs of consents and their status.

The object will be created if the default javascript file is loaded, and a form with the ID #elc-cookie-consent-form exists and has the `data-show`-attribute has the url to the consent show endpoint(/cookie-consent/show)

Acknowledgements
----------------

[](#acknowledgements)

Plugin Icon designed by Trinh Ho from Flaticon

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 95% 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 ~54 days

Total

38

Last Release

605d ago

Major Versions

1.6.1 → 4.0.02022-05-23

4.0.4 → 5.0.02024-04-19

### Community

Maintainers

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

---

Top Contributors

[![jellingsen](https://avatars.githubusercontent.com/u/14084128?v=4)](https://github.com/jellingsen "jellingsen (115 commits)")[![mikewink](https://avatars.githubusercontent.com/u/85063626?v=4)](https://github.com/mikewink "mikewink (2 commits)")[![sieir](https://avatars.githubusercontent.com/u/8918615?v=4)](https://github.com/sieir "sieir (2 commits)")[![jtrobinson1993](https://avatars.githubusercontent.com/u/25162360?v=4)](https://github.com/jtrobinson1993 "jtrobinson1993 (1 commits)")[![white-lukas](https://avatars.githubusercontent.com/u/171683841?v=4)](https://github.com/white-lukas "white-lukas (1 commits)")

---

Tags

cookiesgdprconsent

### Embed Badge

![Health badge](/badges/elleracompany-craft-cookie-consent/health.svg)

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

###  Alternatives

[spicyweb/craft-neo

A Matrix-like field type with block hierarchy

393813.5k10](/packages/spicyweb-craft-neo)[whitecube/laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way.

498731.9k2](/packages/whitecube-laravel-cookie-consent)[verbb/formie

The most user-friendly forms plugin for Craft.

102393.6k70](/packages/verbb-formie)[statikbe/laravel-cookie-consent

Cookie consent modal for EU

219426.2k](/packages/statikbe-laravel-cookie-consent)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54681.3k19](/packages/solspace-craft-freeform)[verbb/vizy

A flexible visual editor field for Craft.

4250.4k](/packages/verbb-vizy)

PHPackages © 2026

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