All Projects → Alex-D → Cookies Eu Banner

Alex-D / Cookies Eu Banner

Licence: mit
1kb vanilla JS script which manages cookies consent banner display like asked by GDPR

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cookies Eu Banner

privera
Use the tools you know. Respect users' privacy. Forget cookie consents. Comply with GDPR, ePrivacy, COPPA, CalOPPA, PECR, PIPEDA, CASL; you name it.
Stars: ✭ 23 (-92.94%)
Mutual labels:  cookie, google-analytics, gdpr
Klaro
Klaro! A privacy and security tool for your website.
Stars: ✭ 640 (+96.32%)
Mutual labels:  gdpr, cookie
Simple Cookie Choices
A simple cookie choices thought to the GDPR rules 🔒🍪
Stars: ✭ 12 (-96.32%)
Mutual labels:  gdpr, cookie
Goaccess
GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
Stars: ✭ 14,096 (+4223.93%)
Mutual labels:  gdpr, google-analytics
Web Analytics
监测分析、异常监测、广告验证、访客唯一标识
Stars: ✭ 97 (-70.25%)
Mutual labels:  google-analytics, cookie
tag-manager
Website analytics, JavaScript error tracking + analytics, tag manager, data ingest endpoint creation (tracking pixels). GDPR + CCPA compliant.
Stars: ✭ 279 (-14.42%)
Mutual labels:  google-analytics, gdpr
Cookiescanner
Cookie Scanner for GDPR compliance
Stars: ✭ 126 (-61.35%)
Mutual labels:  gdpr, cookie
javascript-cookie-control
Javascript module for controling cookie consent on your website
Stars: ✭ 18 (-94.48%)
Mutual labels:  cookie, gdpr
silverstripe-cookie-consent
GDPR compliant cookie popup and consent checker
Stars: ✭ 16 (-95.09%)
Mutual labels:  cookie, gdpr
react-cookie-law
React Cookie Law is a cookie-info banner compliance with the GDPR and the EU cookie law. It allows the user to give consent in a granular way.
Stars: ✭ 103 (-68.4%)
Mutual labels:  cookie, gdpr
PolishCookieConsent
Polish Cookie Consent is an extension, which automatically accepts privacy policy/GDPR on websites.
Stars: ✭ 17 (-94.79%)
Mutual labels:  cookie, gdpr
gdpr-cookie
Php Cookie checker for Analytics and Tawk.To (GDPR Compliance)
Stars: ✭ 21 (-93.56%)
Mutual labels:  cookie, gdpr
Hybrid Navigation
React Native Navigation that supports seamless navigation between Native and React.
Stars: ✭ 258 (-20.86%)
Mutual labels:  navigator
Browserslist Ga
🦔 Target browsers tailored to your audience using Google Analytics
Stars: ✭ 280 (-14.11%)
Mutual labels:  google-analytics
Cookies.js
Simple cookie framework with full Unicode support
Stars: ✭ 254 (-22.09%)
Mutual labels:  cookie
database-anonymizer
CLI tool an PHP library to anonymize data in various databases
Stars: ✭ 23 (-92.94%)
Mutual labels:  gdpr
Vue Cookies
A simple Vue.js plugin for handling browser cookies
Stars: ✭ 293 (-10.12%)
Mutual labels:  cookie
Angular Local Storage
An AngularJS module that gives you access to the browsers local storage with cookie fallback
Stars: ✭ 2,862 (+777.91%)
Mutual labels:  cookie
typo3-dp cookieconsent
TYPO3 Extension: Enable a cookie consent box. Let you visitors control the usage of cookies and load script or content after a consent. (ePrivacy, TTDSG)
Stars: ✭ 28 (-91.41%)
Mutual labels:  cookie
wp-gdpr-cookie-notice
Simple performant cookie consent notice that supports AMP, Web Stories, granular cookie control and live preview customization.
Stars: ✭ 17 (-94.79%)
Mutual labels:  gdpr

Cookies EU banner

Minzipped size 1kb Downloads MIT Licence
Version on npm Version on bower

Screenshot

Supporting Cookies EU banner

Cookies EU banner is an MIT-licensed open source project and completely free to use. You can support it's ongoing development by being a backer or a sponsor:


Introduction

Cookies EU banner manage display of a banner which allows user to accept or reject cookies from tracking services like Google Analytics. It is a GDPR-compliant way to get cookie consent from visitors.

Installation

Get the script

  • Using npm: npm install cookies-eu-banner --save
  • Or using yarn: yarn add cookies-eu-banner
  • Or using bower: bower install cookies-eu-banner --save
  • Or download the latest version.

In your pages

Insert the banner before any content at the beginning of the <body> element, with these IDs:

<div id="cookies-eu-banner" style="display: none;">
    By continuing to visit this site, you accept the use of cookies by Google Analytics for statistical purposes.
    <a href="./read-more.html" id="cookies-eu-more">Read more</a>
    <button id="cookies-eu-reject">Reject</button>
    <button id="cookies-eu-accept">Accept</button>
</div>
  • #cookies-eu-banner is the div that contains all elements to be hidden after user accepts or declines the use of cookies;
  • #cookies-eu-more is a link to a "Read more" page where you explain your use of cookies;
  • #cookies-eu-reject and #cookies-eu-accept are the buttons used to reject/accept cookies.

Before the end of <body>, or in a script file inserted at the same place, put the following code:

<script src="cookies-eu-banner/dist/cookies-eu-banner.min.js"></script>
<script>
    new CookiesEuBanner(function () {
        // Your code to launch when user accept cookies
    });
</script>

Example for Google Analytics:

<script src="cookies-eu-banner/dist/cookies-eu-banner.min.js"></script>
<script>
    new CookiesEuBanner(function () {
        (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','//www.google-analytics.com/analytics.js','ga');

        // Don't forget to put your own UA-XXXXXXXX-X code
        ga('create', 'UA-XXXXXXXX-X', 'auto');
        ga('send', 'pageview');
    });
</script>

Options

waitAccept

The second parameter (true in the example below) define if Cookie EU banner wait the user acceptation before hide the banner. Set to false by default.

<script>
    new CookiesEuBanner(function () {
        // Your code to launch when user accept cookies
    }, true);
</script>

useLocalStorage

If you really don't want save the consent in a cookie, you can use localStorage.

The third parameter (true in the example below) define if Cookie EU banner use localStorage (true) or cookie (false). Set to false by default.

Note: the localStorage method is not as good as the cookie method since the localStorage cannot expires after 13 months as recommended.

<script>
    new CookiesEuBanner(function () {
        // Your code to launch when user accept cookies
    }, false, true);
</script>

waitRemove

If you want add some transition on accept/reject, and want to prevent the premature deletion of the banner, you can add data-wait-remove attribute to the banner, with the time to wait in milliseconds.

<div id="cookies-eu-banner" style="display: none;" data-wait-remove="250">
    <!-- ... -->
</div>

How does it work?

For a detailed explanation, see comments in the main file: cookies-eu-banner.js.

In short:

  1. Excludes bots, clients who have DoNotTrack activated, and users who have already declined;
  2. Runs your custom function if user has already accepted;
  3. Shows banner, then:
    • if user accepts, run custom function and put a cookie to save this acceptance;
    • if user declines, remove all Google Analytics cookies and put a cookie to save this rejection.

Features

  • Do Not Track detection (IE9+, Firefox, and all browsers compatible with the navigator.doNotTrack JavaScript variable);
  • Disables banner when visitor is a bot: prevents SEO Engines to confuse your cookie advert message with the main content of your pages;
  • Respects all points imposed by CNIL (FR) and these points.

Contribute

This project use Gulp. To contribute, you need Node.js and npm (or yarn). Then, in the Cookies EU banner folder, run these commands:

npm install
npm run start

# or

yarn
yarn start

The first line install all dependencies. The second line builds the min file and watch for changes to rebuild it on the fly.

Supported browsers

All browsers desktop/mobile: IE8+, Edge, Firefox, Chrome, Safari, Opera, ...

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].