PHPackages                             lerni/klaro-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. lerni/klaro-cookie-consent

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

lerni/klaro-cookie-consent
==========================

Klaro Silverstripe Integration

6.x-dev(7mo ago)65.9k↑166.7%2[2 PRs](https://github.com/lerni/klaro-cookie-consent/pulls)BSD-3-ClausePHPCI failing

Since Mar 30Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/lerni/klaro-cookie-consent)[ Packagist](https://packagist.org/packages/lerni/klaro-cookie-consent)[ Docs](https://github.com/lerni/klaro-cookie-consent)[ RSS](/packages/lerni-klaro-cookie-consent/feed)WikiDiscussions 5.x Synced 1mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

Silverstripe Klaro! Consent Manager
===================================

[](#silverstripe-klaro-consent-manager)

Silverstripe Klaro! implements [KIProtect/klaro](https://github.com/KIProtect/klaro) for GDPR-compliant cookie consent management with Google Consent Mode v2 support.

Quick Start
-----------

[](#quick-start)

1. `composer require lerni/klaro-cookie-consent`
2. `dev/build`
3. `dev/tasks/klaro-defaults` (default values for SiteConfig)
4. Go to **/admin/settings#Root\_CookieConsent** and enable "Cookie Is Active" &amp; configureyour needs

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

[](#requirements)

- SilverStripe CMS ^5 or ^6
- PHP ^8.1

### Suggested Modules

[](#suggested-modules)

- `lerni/silverstripe-tracking` - for Google Analytics, GTM, and Clarity integration

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

[](#installation)

```
# For SilverStripe 5.x (current)
composer require lerni/klaro-cookie-consent
# For SilverStripe 6.x
composer require lerni/klaro-cookie-consent:6.x-dev

# Legacy versions
composer require lerni/klaro-cookie-consent:v2-dev  # SS 4.x/5.x
composer require lerni/klaro-cookie-consent:3.x-dev # SS 3.x
```

CookieEntries &amp; CookieCategories are automatically populated. To add values to SiteConfig use the task below, it populates SiteConfig with default translations from Klaro and applies custom translations from your language file.

```
php ./vendor/silverstripe/framework/cli-script.php dev/tasks/klaro-defaults
```

### Overriding Defaults

[](#overriding-defaults)

Defaults can always be overridden, for example to start with only essential cookies (PHPSESSID, klaro), create `app/_config/klaro_defaults.yml` before DB is populated with `dev/build`.

```
---
Name: empty_klaro_defaults
After: klaro_defaults
---
Kraftausdruck\Models\CookieEntry:
  default_records: null
---
Name: my_klaro_defaults
After: empty_klaro_defaults
---
Kraftausdruck\Models\CookieEntry:
  default_records:
    Klaro:
      Title: 'klaro! consent manager'
      Purpose: 'Stores consent and rejection of cookies.'
      CookieName: 'klaro'
      CookieKey: 'klaro'
      Default: 'false'
      OptOut: 'false'
      CookieCategoryID: 1
    PHPSESSID:
      Title: 'PHP Session'
      Purpose: 'Stores PHP session ID for unique user identification.'
      CookieName: 'PHPSESSID'
      CookieKey: 'PHPSESSID'
      Default: 'true'
      OptOut: 'false'
      CookieCategoryID: 1
```

Basic Usage
-----------

[](#basic-usage)

### CMS Configuration

[](#cms-configuration)

1. **Settings &gt; Cookie Consent**
2. Enable "Cookie Is Active"
3. Configure services (Google Analytics, GTM, etc.)
4. Customize consent modal text and appearance

### Adding Consent Links

[](#adding-consent-links)

```

Cookie Settings

[ConsentLink beforeText="Manage your " afterText=" preferences"]
```

### Managing Third-Party Scripts

[](#managing-third-party-scripts)

Replace `src` with `data-src` and add consent attributes:

```

```

Consent Mode v2 Support
-----------------------

[](#consent-mode-v2-support)

Support for Google's privacy-compliant tracking with consent updates.

### Default Services Included

[](#default-services-included)

- **Google Tag Manager**
- **Google Analytics**
- **Google Ads**
- **Microsoft Clarity**

Advanced Configuration
----------------------

[](#advanced-configuration)

### Custom Consent Callbacks

[](#custom-consent-callbacks)

Configure custom JavaScript for each service in **Settings &gt; Cookie Consent**:

```
// Google Analytics example
OnAccept: if(typeof gtag === "function") { gtag("consent", "update", { analytics_storage: "granted" }); }
OnDecline: if(typeof gtag === "function") { gtag("consent", "update", { analytics_storage: "denied" }); }

// Microsoft Clarity example
OnAccept: if(typeof clarity === "function") { clarity("consentv2", { ad_Storage: "granted", analytics_Storage: "granted" }); }
OnDecline: if(typeof clarity === "function") { clarity("consentv2", { ad_Storage: "denied", analytics_Storage: "denied" }); }
```

### Google Tag Manager Integration

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

When using with `lerni/silverstripe-tracking`, GTM events are automatically fired based on the callbacks set in CMS:

**Default Events:**

- `klaro-google-analytics-accepted/declined`
- `klaro-google-ads-accepted/declined`
- `klaro-google-tag-manager-accepted/declined`

**Setting up GTM Triggers:**

1. Create **Custom Event** trigger in GTM
2. Use event name (e.g., `klaro-google-analytics-accepted`)
3. Fire your tracking tags based on consent

### Configuration Override

[](#configuration-override)

Override defaults in your `app/_config/klaro.yml`:

```
Kraftausdruck\Models\CookieEntry:
  default_records:
    Analytics:
      Title: 'Custom Analytics Title'
      # Override any default settings
```

Styling Customization```
// Example SCSS customization
html .klaro {
	--notice-max-width: 440px;
	.cookie-modal,
	.cookie-notice {
		z-index: 9100;
		a {
			color: lighten($link-color, 70%);
		}
		.cm-btn {
			cursor: pointer;
			font-size: 14px;
			border-radius: 0.1em;
			margin-right: 1.2em;
			padding-top: .6em;
		}
	}

	.cookie-notice {
		.cn-body {
			border: 1px solid $gray;
			border-radius: 0.1em;
			// klaro sets font-size on block elements - we're calculating back to maintain horizontal spacing :-/
			@media (max-width: 1023px) {
				padding-right: #{$lh * math.div($font-size, 14px)}em !important;
				padding-left: #{$lh * math.div($font-size, 14px)}em !important;
				@include breakpoint($Mneg) {
					padding-right: #{0.5 * $lh * math.div($font-size, 14px)}em !important;
					padding-left: #{0.5 * $lh * math.div($font-size, 14px)}em !important;
				}
			}
		}
		h2 {
			font-size: 1.1em;
			margin-top: 0.6em;
		}
		p {
			margin: 0.3em 0 !important;
		}
		.cn-ok {
			display: flex;
			flex-wrap: wrap;
			justify-content: flex-start !important;
			.cn-buttons {
				display: flex !important;
				order: 1;
				// decline
				.cm-btn.cn-decline {
					background-color: $gray;
					order: 1;
				}
				// accept all
				.cm-btn.cm-btn-success {
					background-color: $link-color;
					order: 0;
				}
			}
			// modal link
			.cn-learn-more {
				display: block;
				margin-right: 0;
				order: 2;
				flex: 0 0 auto;
				padding: 0.5em 0;
			}
		}
	}

	.cookie-modal {
		.cm-modal {
			border: 1px solid $gray;
		}
		.cm-header a {
			@include bold;
		}
		.cm-app-title {
			font-size: 14px;
		}
		// switch disabled
		.cm-list-label .slider {
			background-color: $gray;
		}
		// slider-switches
		.cm-list-input:checked + .cm-list-label .slider {
			background-color: $link-color;
		}
		// required switch enabled
		.cm-list-input.required:checked + .cm-list-label .slider {
			background-color: darken($link-color, 10%);
			&::before {
				background-color: darken($white, 16%);
			}
		}
		// halve is used on parent if children are on & off
		.cm-list-input.only-required + .cm-list-label .slider,
		.cm-list-input.half-checked:checked + .cm-list-label .slider {
			background-color: mix($link-color, $white, 71%);
		}
		.cm-list-description {
			color: $gray--light;
		}
		// accept all
		.cm-btn.cm-btn-accept-all {
			background-color: $link-color;
		}
		// save selection, decline
		.cm-btn.cm-btn-accept,
		.cm-btn.cm-btn-decline {
			background-color: $gray;
		}
		.cm-btn.cm-btn-accept {
			order: 99;
			margin-right: 0;
		}
		// klaro link
		.cm-modal .cm-footer .cm-powered-by {
			display: none;
		}
	}
}
// klaro! contextual consent
[data-type="placeholder"] {
	position: absolute;
	background-color: $gray--light;
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	width: 100%;
	height: 100%;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	padding: #{$lh}em;
	.cm-as-context-notice {
		height: auto;
	}
	.context-notice {
		&:last-child {
			margin-bottom: 0;
		}
		.cm-buttons {
			display: flex;
			gap: 1em;
		}
		button.cm-btn {
			display: inline-block;
			padding: #{math.div($lh, 4)}em #{math.div($lh, 2)}em;
			border: none;
			text-transform: uppercase;
			color: $white;
			font-size: 1em;
			@include bold;
			border-radius: 0;
			margin: 0 !important;
			cursor: pointer;
			&:first-of-type {
				background-color: $link-color;
			}
			&:last-of-type {
				background-color: mix($link-color, $gray--light, 70%);
			}
			&:not(:last-of-type) {
				margin-right: #{$lh}em;
			}
		}
	}
}
```

Resources
---------

[](#resources)

- [Klaro! Documentation](https://klaro.kiprotect.com/docs), [Annotated Config](https://klaro.org/docs/integration/annotated-configuration)
- [Google Consent Mode v2 Guide](https://developers.google.com/tag-platform/security/guides/consent)
- [SilverStripe Configuration Documentation](https://docs.silverstripe.org/en/developer_guides/configuration/)

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance66

Regular maintenance activity

Popularity29

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.5% 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 ~422 days

Total

4

Last Release

237d ago

Major Versions

v2.x-dev → 6.x-dev2025-09-16

### Community

Maintainers

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

---

Top Contributors

[![lerni](https://avatars.githubusercontent.com/u/472115?v=4)](https://github.com/lerni "lerni (65 commits)")[![BettinaMaria98](https://avatars.githubusercontent.com/u/50010683?v=4)](https://github.com/BettinaMaria98 "BettinaMaria98 (1 commits)")

---

Tags

consentcookiesilverstripesilverstripecookiegdprconsentdsgvoePrivacyKlaroconsent mode v2

### Embed Badge

![Health badge](/badges/lerni-klaro-cookie-consent/health.svg)

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

###  Alternatives

[statikbe/laravel-cookie-consent

Cookie consent modal for EU

213396.7k](/packages/statikbe-laravel-cookie-consent)[dirkpersky/typo3-dp_cookieconsent

Enable a cookie consent box. Let you visitors control the usage of cookies and load script or content after a consent. (ePrivacy, TTDSG)

36201.3k1](/packages/dirkpersky-typo3-dp-cookieconsent)[bramdeleeuw/cookieconsent

GDPR compliant cookie bar and consent checker

1511.5k2](/packages/bramdeleeuw-cookieconsent)[codingfreaks/cf-cookiemanager

Manage cookies, scripts, and GDPR compliance on your Typo3 website with CodingFreaks Typo3 Cookie Manager. Customize cookie banners, streamline workflow, and enhance user experience. Ensure GDPR compliance and take control of cookie management with our Typo3 cookie management extension. Visit the official Typo3 Documentation page to learn more.

1625.8k](/packages/codingfreaks-cf-cookiemanager)

PHPackages © 2026

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