
👋 Hey, I'm Amauri, a french dev that build a GDPR friendly cookie manager.
tarteaucitron was initially a simple script for my personal blog (in 2013), a few months later, the Github repository is opened and tarteaucitron is now reliable and recognized.
The european cookie law regulates the management of cookies and you should ask your visitors their consent before exposing them to third party services.
Clearly this script will:
- Disable all services by default,
- Display a banner on the first page view and a small one on other pages,
- Display a panel to allow or deny each services one by one,
- Store the consent in a cookie for 365 days.
Bonus:
- Load service when user click on Allow (without reload of the page),
- Incorporate a fallback system (display a link instead of social button and a static banner instead of advertising).
How to use
<script src="/tarteaucitron/tarteaucitron.js"></script>
<script>
tarteaucitron.init({
"privacyUrl": "",
"bodyPosition": "bottom",
"hashtag": "#tarteaucitron",
"cookieName": "tarteaucitron",
"orientation": "middle",
"groupServices": false,
"showDetailsOnClick": true,
"serviceDefaultState": "wait",
"showAlertSmall": false,
"cookieslist": false,
"cookieslistEmbed": false,
"showIcon": true,
"iconPosition": "BottomRight",
"adblocker": false,
"DenyAllCta" : true,
"AcceptAllCta" : true,
"highPrivacy": true,
"alwaysNeedConsent": false,
"handleBrowserDNTRequest": false,
"removeCredit": false,
"moreInfoLink": true,
"useExternalCss": false,
"useExternalJs": false,
"readmoreLink": "",
"mandatory": true,
"mandatoryCta": true,
"googleConsentMode": true,
"bingConsentMode": true,
"pianoConsentMode": true,
"pianoConsentModeEssential": false,
"softConsentMode": false,
"dataLayer": false,
"serverSide": false,
"partnersList": false
});
</script>
Add a service
Installation guide
Customization
Create custom service
tarteaucitron.services.mycustomservice = {
"key": "mycustomservice",
"type": "ads|analytic|api|comment|other|social|support|video",
"name": "MyCustomService",
"needConsent": true,
"cookies": ['cookie', 'cookie2'],
"readmoreLink": "/custom_read_more",
"js": function () {
"use strict";
},
"fallback": function () {
"use strict";
}
};
Events
The following events are available:
-
(document) {SERVICE_KEY}_added for each enabled service
-
(document) {SERVICE_KEY}_loaded for each enabled service
-
(document) {SERVICE_KEY}_allowed for each service when allowed
-
(document) {SERVICE_KEY}_disallowed for each service when disallowed
-
(window) tac.root_available: the root element with panel has been created, services will be loaded
-
(window) tac.open_alert
-
(window) tac.close_alert
-
(window) tac.open_panel
-
(window) tac.close_panel
Customize text
To change a translation, use tarteaucitronCustomText variable. It will be merge with the translation shipping with TAC. This variable must be defined before the initialization. For example:
tarteaucitronCustomText = {
'support': {
'title': 'Support client',
},
'close': 'Enregistrer et fermer',
};
tarteaucitron.init(...);
There is a special case for engagement text. By the default, the engagement text is {SERVICE_NAME} is disabled., however you can change it per service. For example:
tarteaucitronCustomText = {
'engage-twitter': 'Follow us on Twitter!'
};