A minimal plugin to add all tiers-scripts and accept them.
npm install gatsby-plugin-rgpd-acceptanceYet Another plugin to manage third-party scripts, respecting the GDPR.
This plugin is not specific to one solution (e.g. Google Analytics, Facebook pixel, YouTube, etc.), it can use and drive them all.
You just have to declare the whole script or an URL to load.
> All consents datas are stored in localStorage.
Two components are provided:
- RGPDCookieBanner which is used to display and manage the acceptance.
- RGPDBlocker which is used to prevent the loading of code (e.g. YouTube iframe, navigation map, playlist, etc.) if the person has not explicitly given his consent.
Two modes are proposed, one where the banner component is automatically added and a manual mode where you have to add it yourself.
To use the manual mode, it in the gatsby-config.js plugin options. Change the value of useInternalComponent to false.
| RGPDCookieBanner | RGPDBlocker |
| --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| Full version, not accepted:!RGPDCookieBanner | Not accepted version:
!RGPDBlocker not accepted |
| Accepted version:
!RGPDCookieBanner mini | Accepted version:
!RGPDBlocker accepted |
| Choosing view without mandatory cookie:
!RGPDCookieBanner choosing view without mandatory cookie | |
| Choosing view with mandatory cookie:
!RGPDCookieBanner choosing view with mandatory cookie | |
npm i gatsby-plugin-rgpd-acceptance
``javascriptgatsby-plugin-rgpd-acceptance
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: ,google-analitics
options: {
cookieDuration: 365, // Optionnal, default value: one year in days
useInternalCss: true, // Boolean Optionnal, default value: true
useInternalComponent: true, // Boolean Optionnal, default value: true
labels: {
// See below
},
cookiesList: [
// At least one is required (otherwise, what is the point of installing this plugin).
// See below for all explaination
{
key: , // Required, your internal keyGoogle Analytics
publicName: , // Required, a Friendly NameGA Description
publicDescription: , // Required, a Friendly Descriptionanalytic
type: , // Required, a type/usage of script, chose one of them ads|analytic|api|comment|other|social|support|videohttps://test.io
mandatory: true, // Boolean Required, set if this script is mandatory
urlToCall: , // Optional (otherwise, enter scriptToInclude), the url of your script.
scriptToInclude: , // Optional (otherwise, enter urlToCall), the url of your script.`
},
// ...
],
},
},
],
}
| Name | Default | Description |
| --------------------------- | ----------------------------------------- | -------------------------------------------------------------------------- |
| cookieDuration | 365 | How long the acceptance is still validate |useInternalCss
| | true | Active the internal demo style |useInternalComponent
| | true | Add automatically the RGPDCookieBanner component |labels
| | {\*} Object | The different labels of the RGPDCookieBanner component |labels.icon
| | 🍪 | The icon used in both version of RGPDCookieBanner component |labels.titleBanner
| | Les cookies | Title of the RGPDCookieBanner |labels.descriptionBanner
| | Nous utilisons des cookies [...] | Description text (complete text below) of the RGPDCookieBanner |labels.acceptAllLabel
| | Accepter tout | Button label of RGPDCookieBanner |labels.rejectAllLabel
| | Rejeter tout | Button label of RGPDCookieBanner |labels.chooseLabel
| | Choisir | Button label of RGPDCookieBanner |labels.saveLabel
| | Enregistrer | Button label of RGPDCookieBanner |labels.mandatoryLabel
| | obligatoire | information to indicate the cookie is mandatory |labels.blockerWarnLabel
| | Accepter | Button label of RGPDBlocker |labels.blockerWarnMessage
| | Vous n'avez pas accepté les cookies [...] | Description text (complete text below) of the RGPDBlocker |cookiesList
| | [\*] Array of objects | The configuration Array of each cookie, at least 1 is mandatory |key
| | - | Required, your internal key |publicName
| | - | Required, a Friendly Name |type
| | - | Required, a type/usage of script, chose one of them (list below) |mandatory
| | - | Boolean Required, a set if this script is mandatory |urlToCall
| | - | Optional, (otherwise, enter scriptToInclude), the URL of your script |scriptToInclude
| | - | Optional, (otherwise, enter urlToCall), the URL of your script |
> type of cookie :
>
> - adsanalytic
> - api
> - comment
> - other
> - social
> - support
> - video
> -
> descriptionBanner default value:
> Nous utilisons des cookies et des technologies similaires sur notre site web et traitons vos données personnelles (par exemple, l'adresse IP), par exemple, pour personnaliser le contenu et les annonces, pour intégrer des médias de fournisseurs tiers ou pour analyser le trafic sur notre site web.<br/> Le traitement des données peut également se produire à la suite de la mise en place de cookies. Nous partageons ces données avec des tiers que nous nommons dans les paramètres de confidentialité. Le traitement des données peut avoir lieu avec votre consentement ou sur la base d'un intérêt légitime, auquel vous pouvez vous opposer dans les paramètres de confidentialité. Vous avez le droit de ne pas consentir et de modifier ou révoquer votre consentement ultérieurement. Pour plus d'informations sur l'utilisation de vos données, veuillez consulter notre politique de confidentialité.
> blockerWarnMessage default value:
> Vous n'avez pas accepté les cookies globalement ou celui-ci précisement.<br/> Pour afficher ce contenu, vous devez accepter.
The design is intentionally horrible. So, you can/should adapt it by disabling it in the gatsby-config.js plugin options. Change the value of useInternalCss to false
Here are the CSS classes (the names speak for themselves)
If you set useInternalCss a rgpd-acceptance-theme class is added to . So, you don't need to put !important to override the predefined styles.
`CSS
/ RGPDCookieBanner and his mini version component /
.rgpd--container
.rgpd--banner
.rgpd--banner.full
.rgpd--header
.rgpd--icon
.rgpd--title
.rgpd--cookies-list
.rgpd--cookie-item
.rgpd--cookie-name
.rgpd--cookie-description
.rgpd--cookie-type
.rgpd--cookie-mandatory
.rgpd--cookie-checkzone
.rgpd--footer
.rgpd--btn
.rgpd--btn.all
.rgpd--btn.some
.rgpd--btn.none
.rgpd--btn.choose
.rgpd--btn.save
.rgpd--banner.mini
.rgpd--icon
.rgpd--link
/ RGPDBlocker component /
.rgpd--blocker--container
.rgpd--blocker--container .rgpd--icon
.rgpd--blocker--title
.rgpd--blocker--warn-message
`
If you set in gatsby-config.js the option useInternalComponent at false you can add it manually in your layout.
> It's mandatory if you need to translate labels with i18n. I you have only one language, you can directely set text in gatsby-config.js.
`javascript`
import { RGPDCookieBanner } from 'gatsby-plugin-rgpd-acceptance'
`javascriptString
/**
* The pilot of acceptance
@param {} icon Emoji Override plugin or config label (eg. for i18n).String
@param {} titleBanner Override plugin or config label (eg. for i18n).String
@param {} descriptionBanner Override plugin or config label (eg. for i18n).String
@param {} acceptAllLabel Override plugin or config label (eg. for i18n).String
@param {} chooseLabel Override plugin or config label (eg. for i18n).String
@param {} rejectAllLabel Override plugin or config label (eg. for i18n).String
@param {} saveLabel Override plugin or config label (eg. for i18n).String
@param {} mandatoryLabel Override plugin or config label (eg. for i18n).Boolean
@param {} asAContainer Add a container with rgpd--container classname.`
* @returns
*/
This component is used to block the loading of a child component that would require an acceptance validation.
If he didn't get it, an alert message is displayed and he can directly accept it by clicking on a button.
By implementing this system, you protect your users from tracking by the third party service used.
`javascriptString
/**
* A component to block the loading of an unaccepted third party script.
@param {} cookieKey Required, your internal key, same as configured in gatsby-config.jsString
@param {} className Optionnal, your style (set width and height)String
@param {} blockerWarnMessage Optionnal, the label of the localy acceptance buttonString
@param {} blockerWarnLabel Optionnal, the warning message.``
* @returns
*/
You can make enhancement requests, report bugs, or simply offer help at https://github.com/NovaGaia/gatsby-plugin-rgpd-acceptance/issues
Create some plugins to facilitate the implemtation of a cookie script (like the others plugins who are specialized).