PHPackages                             la-haute-societe/craft-tarteaucitron - 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. la-haute-societe/craft-tarteaucitron

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

la-haute-societe/craft-tarteaucitron
====================================

Manage your sites' cookies with this tarteaucitron.js Craft CMS 5 integration

3.0.1(3y ago)41.5k1[3 PRs](https://github.com/la-haute-societe/craft-tarteaucitron/pulls)proprietaryPHP

Since Sep 16Pushed 2mo ago6 watchersCompare

[ Source](https://github.com/la-haute-societe/craft-tarteaucitron)[ Packagist](https://packagist.org/packages/la-haute-societe/craft-tarteaucitron)[ RSS](/packages/la-haute-societe-craft-tarteaucitron/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (1)Versions (22)Used By (0)

[![](.readme/logo-tarteaucitron.png)](.readme/logo-tarteaucitron.png)

Craft 5 - tarteaucitron.js
==========================

[](#craft-5---tarteaucitronjs)

Handle GDPR in your Craft CMS projet the easy way with tarteaucitron.js.

This plugin currently support the following services :

- Facebook Pixel
- Google AdWords (conversion)
- Google AdWords (remarketing)
- Google Analytics (universal)
- Google Maps
- Google Tag Manager
- Linkedin
- reCAPTCHA
- Twitter
- Vimeo
- Youtube
- YouTube Js API

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

[](#requirements)

This plugin requires Craft CMS 5.0.0 or later and PHP 8.2+. Version 3.x of this plugin supports Craft CMS 4.x, and version 2.x supports Craft CMS 3.x.

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

[](#installation)

### The easy way

[](#the-easy-way)

Just install the plugin from the Craft Plugin Store.

### From the command line

[](#from-the-command-line)

```
composer require la-haute-societe/craft-tarteaucitron
./craft install/plugin tarteaucitron
```

Tarteaucitron plugin Overview
-----------------------------

[](#tarteaucitron-plugin-overview)

[tarteaucitron.js](https://github.com/AmauriC/tarteaucitron.js) is a javascript library allowing you to handle GDPR compliance on your site. It allows end-users to give their consent before exposing them to third party services (such as Google, Facebook, Twitter…).

This plugin makes the integrating tarteaucitron.js in Craft CMS projects a breeze.

Using the Tarteaucitron plugin
------------------------------

[](#using-the-tarteaucitron-plugin)

### Initialization script

[](#initialization-script)

Add the following twig code in the templates where you want the plugin to be loaded (in the `` section of the layout page for example):

```
{{ craft.tarteaucitron.initScript }}
```

### Loading services

[](#loading-services)

[![Settings page](.readme/settings.png)](.readme/settings.png)

The plugin and its associated services are configurable from the plugin settings page.

To activate a service on your site, you need to activate it and then, depending on the service, add the given Twig code where you want the service to be loaded. The Twig code will output a tarteaucitron.js placeholder, that will get replaced by the content you wanted to load (e.g. a YouTube video, a Google Maps…) once tarteaucitron.js has loaded, and the user has given its consent for the service.

### Service HTML Attributes

[](#service-html-attributes)

For some service templates, you can include a parameter named `htmlAttributes`. This parameter allows you to define html attributes for the html tag associated with the service.

Example :

```
{{ craft.tarteaucitron.vimeo({
    videoId: 'xxxxxxxx',
    width: '500px',
    height: '200px',
    htmlAttributes: {
        class: 'border-black',
    }
}) }}
```

Advanced usage
--------------

[](#advanced-usage)

### Manually instantiating services

[](#manually-instantiating-services)

If for some reason, you'd rather not use the `craft.tarteaucitron.xxx()` methods to instantiate your services, you can always add the tarteaucitron.js placeholder element by yourself.

These two examples will have the exact same result (you still need to enable the Vimeo service in the plugin settings):

```
{{ craft.tarteaucitron.vimeo({
    videoId: 'xxxxxxxx',
    width: '500px',
    height: '200px',
    htmlAttributes: {
        class: 'border-black',
    }
}) }}
```

```

```

### Checking if a service is enabled

[](#checking-if-a-service-is-enabled)

You may need to check whether a service is enabled (as in "enabled in the plugin settings", this has nothing to do with whether the user has given its consent):

```
{% if not craft.tarteaucitron.isTwitterEnabled() %}
    The site admin decided to disable Twitter widgets.
{% endif %}
```

Here are the available `isXXXEnabled()` methods:

- `isFacebookPixelEnabled()`
- `isGoogleTagManagerEnabled()`
- `isReCAPTCHAEnabled()`
- `isGoogleMapsEnabled()`
- `isGoogleAnalyticsUniversalEnabled()`
- `isGoogleAdWordsConversionEnabled()`
- `isGoogleAdWordsRemarketingEnabled()`
- `isLinkedInEnabled()`
- `isTwitterEnabled()`
- `isVimeoEnabled()`
- `isYoutubeEnabled()`

### JS - Dynamically adding elements managed by a service

[](#js---dynamically-adding-elements-managed-by-a-service)

Sometimes you need to dynamically add an element that should be managed by tarteaucitron.js (eg. you load a page fragment containing a Vimeo video using AJAX). Adding the tarteaucitron.js placeholder to the DOM isn't enough. You need to ask tarteaucitron.js to re-render the service :

```
// Create a tarteaucitron.js Vimeo placeholder element and add it to the document
var div = document.createElement('div');
div.className = 'vimeo_player';
div.attributes['data-videoID'] = 'XXXXXX';
div.dataset.width = '500px';
div.dataset.height = '300px';
document.body.appendChild(document.body.firstChild);

// Make tarteaucitron.js re-render the vimeo service
tarteaucitron.services.vimeo[tarteaucitron.state.vimeo ? 'js' : 'fallback']();
```

### JS - Reacting to the user giving its consent to a service

[](#js---reacting-to-the-user-giving-its-consent-to-a-service)

Unfortunately, there is no clean way to do this at the moment, but a PR will be submitted to try to improve tarteaucitron.js.

### Customizing JS output in the page

[](#customizing-js-output-in-the-page)

Instead of using `{{ craft.tarteaucitron.initScript() }}` to output both the tarteaucitron.js tag and the configuration JS tag, use:

- `{{ craft.tarteaucitron.javascriptImportTag() }}` to output just the tarteaucitron.js import tag
- `{{ craft.tarteaucitron.javascriptConfigTag() }}` to output just the tarteaucitron.js configuration inline JS tag

### Customizing CSS output

[](#customizing-css-output)

By default, tarteaucitron.js imports the *css/tarteaucitron.css* stylesheet located next to the *tarteaucitron.js* file. You can prevent this using the `useCustomCss` setting of the plugin. You can provide your own stylesheet or use `{{ craft.tarteaucitron.stylesheetTag() }}` to output the tarteaucitron.js stylesheet import tag

Contribute
----------

[](#contribute)

Want to contribute? See [CONTRIBUTING.md](./CONTRIBUTING.md)

Brought to you by [![Logo La Haute Société](.readme/logo-lahautesociete.png)](https://www.lahautesociete.com)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance56

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 86.3% 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 ~147 days

Recently: every ~463 days

Total

17

Last Release

75d ago

Major Versions

1.1.3 → 2.0.02020-01-31

2.4.1 → 3.0.02022-06-28

3.0.1 → 4.0.0-beta.12026-02-26

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/9fd1947ef8f9b4e7b6f1782c87ade771ff646d15941f6e5347605bdf16fada71?d=identicon)[la-haute-societe](/maintainers/la-haute-societe)

![](https://www.gravatar.com/avatar/53cf2ceb2a348849e2038a7eb2e32f0782ea0ea31a468da7661fcbf18420fac6?d=identicon)[nstcactus](/maintainers/nstcactus)

---

Top Contributors

[![nstCactus](https://avatars.githubusercontent.com/u/353843?v=4)](https://github.com/nstCactus "nstCactus (82 commits)")[![Jose-Ferreira-LHS](https://avatars.githubusercontent.com/u/263881028?v=4)](https://github.com/Jose-Ferreira-LHS "Jose-Ferreira-LHS (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![lhs-dev](https://avatars.githubusercontent.com/u/50990957?v=4)](https://github.com/lhs-dev "lhs-dev (4 commits)")

---

Tags

cmscraftcraft-plugincraftcmsgdprrgpdtarteaucitroncmsCraftcraftcmscraft-plugingdprrgpdtarteaucitron

### Embed Badge

![Health badge](/badges/la-haute-societe-craft-tarteaucitron/health.svg)

```
[![Health](https://phpackages.com/badges/la-haute-societe-craft-tarteaucitron/health.svg)](https://phpackages.com/packages/la-haute-societe-craft-tarteaucitron)
```

###  Alternatives

[verbb/navigation

Create navigation menus for your site.

90683.7k17](/packages/verbb-navigation)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[verbb/tablemaker

Create customizable and user-defined table fields.

40168.8k1](/packages/verbb-tablemaker)[supercool/tablemaker

Create customizable and user-defined table fields.

40141.7k](/packages/supercool-tablemaker)[pennebaker/craft-architect

CraftCMS plugin to generate content models from JSON/YAML data.

72148.5k5](/packages/pennebaker-craft-architect)

PHPackages © 2026

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