Code Monkey home page Code Monkey logo

gdpr-cookie-notice's Introduction

GDPR Cookie Notice

This is a javascript solution to show a gdpr compliant cookie notice on your website.

Demo

Check this site for a quick demo: https://passatgt.github.io/gdpr-cookie-notice/

How it works?

Include the scripts.js and style.css files on your site from the dist folder. Init the script with the following config file:

gdprCookieNotice({
  locale: 'en', //This is the default value
  timeout: 500, //Time until the cookie bar appears
  expiration: 30, //This is the default value, in days
  domain: '.yoursite.com', //If you run the same cookie notice on all subdomains, define the main domain starting with a .
  implicit: true, //Accept cookies on page scroll automatically
  statement: 'https://google.com', //Link to your cookie statement page
  performance: ['JSESSIONID'], //Cookies in the performance category.
  analytics: ['ga'], //Cookies in the analytics category.
  marketing: ['SSID'] //Cookies in the marketing category.
});

User will see a banner at the bottom of the screen, describing why the site runs cookies. Clicking on Cookie settings will let the user select which type of cookies they might allow on the site(if something is not allowed, all cookies defined in the config file will be deleted automatically on page load). The bar will be visible always if they don't allow all types of cookies to load, just to annoy them a little.

You can use listen to the gdprCookiesEnabled event to load scripts on your site only when the cookies are enabled by the user.

gdpr-cookie-notice's People

Contributors

czende avatar ellingen avatar greystate avatar mcebular avatar mezanddav avatar mrbig00 avatar noldtech avatar passatgt avatar puckey avatar striezel avatar zalog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdpr-cookie-notice's Issues

Typo performance

Hi,
There is a typo in performance: in the script and in the call the N is missing.

Cookie

Congratulations for the script! But where should I enter the cookie script on the page? I tried to insert the analytics script but they are not deactivated in any way whith your script. Thank you so much

`
<script src="dist/script.js" type="text/javascript"></script>

<script>
gdprCookieNotice({
  statement: '/cookies',
  performace: ['JSESSIONID'],
  analytics: ['_gat', '_gid', '_ga'],
  marketing: ['SSID']
});
</script>

<script type="text/javascript">
document.addEventListener('gdprCookiesEnabled', function (e) {
  console.log(e);
  if(e.detail.marketing) {
    console.log('marketing cookies are enabled');
  }
});
</script>


  <script>

(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','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-xxxxxxxx-1', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');

</script>`

Settings Modal Not Opening

This looks like a great cookie consent solution for GDPR compliance; exactly what I hoped I'd find.

I've run into a problem, however.

I've followed the instructions as far as implementing the gdprCookiesEnabled event, but the modal box isn't opening when I click on 'Cookie Settings' – nor if I click a button I've added to my Cookies policy. I can't seem to find out why this might be. Can anyone help?

[Happy to provide further info if needed]

import locale language

Hello,
I cannot import the lang (fr) file.

import {gdprCookieNotice} from 'exports-loader? exports = gdprCookieNotice! gdpr-cookie-notice / dist / script.js';

gdprCookieNotice ({
locale: 'fr', // This is the default value
timeout: 500, // Time until the cookie bar appears
expiration: 30, // This is the default value, in days
implicit: false, // Accept cookies on page scroll automatically
statement: 'https://google.com', // Link to your cookie statement page
performance: ['JSESSIONID'], // Cookies in the performance category.
analytics: ['ga'], // Cookies in the analytics category.
marketing: ['SSID'], // Cookies in the marketing category.
});

my problem is that it always stays in.

Can you help me?

PS: I am under webpack

@@History/@@scroll|# Cookie

Hi, thanks again for this solution – it pretty much does the job for me and my site.

Apologies for this more general question, but hopefully someone has the answer. My site seems to be setting this cookie: @@History/@@scroll|#. I've included it in the config file, but using Cookiebot to scan my site for compliance tells me it's the only cookie that prior consent has not been given.

This solution is working for all other cookies, just not this one. I don't even know what site is setting this persistent cookie and it doesn't show up in Chrome's Dev Console. Can anyone help.

Apart from that, many thanks again.

Few errors/corrections

Hi,

An excellent bit of code. Few minor issues:

The example in the readme

marketing: [SSID'] //Cookies in the marketing category.

You are missing a ' in there. Should be

marketing: ['SSID'] //Cookies in the marketing category.

You also need to note the script needs the init at the bottom of the page, before closing body tag.

Option to change cookie settings?

Hi,
In the demo when you click Accept all cookies, the bar disappears but then there is no option anymore to change the settings when you change your mind. An change option is required by the GDPR law as far as I know.

doesn't work in IE11

Hello!
Thanks for this great solution!

But it doesn't work in IE11. I can't fix it, maybe you can help me?

thanks in advance

Cookies settings behavior

First thanks for sharing the script. I have a question regarding the global behavior. You show the notice if not all categories are enabled

    if(notAllEnabled) {
      showNotice();
    } else {
      hideNotice();
    }

Seems weird as gdprcookienotice is part of necessary cookies and in this case if user decline all other categories, notice should not be shown again. BTW you have add the ability to trigger the modal with custom button using gdpr-cookie-notice-settings-button class on any element.

Thanks to clarify why we need to allow all categories to stop showing the notice

Greg

Modal popup

Great script!
I was wondering, in the modal popup you have the 3 categories and a triangle button on the right for each category. I was expecting, when you click on this a list of marketing cookies would be displayed with the option of turning them on or off individually.

Is this the case or should the triangle button be removed?

Regards,
Geoff

Loading of all scripts even if not enabled

Hi, thanks for this code.

That's exactly what I was looking for.

The only thing I noticed is that even when the user decides to disable all cookies they are still activated.

Why does this happen?

How can I solve it?

Sincerely,
Feduzi Matteo.

license

I would like to use (and contribute to) this library, but I would prefer not to have to disclose the source code of any project that I include this cookie notice in..

Would it be possible to use a license for this library that does not include the condition of making available the complete source code of larger works that contain this library? For example the MIT license...

Cookies added via Websocket

Hi

Any idea how to handle cookies that are set via websocket like Chat (Zopim, Olark…)

Seems that the gdpr-cookie-notice is not able to refuse them, says they are wrote again on each page refresh.

Thanbks
Greg

gdprCookiesEnabled event not running on page load

Is there a way to trigger the gdprCookiesEnabled event when the user loads the page? As of now the only time this event triggers is when the user accepts the cookies. Is this intentional or am I missing something?

Error if all categories not included in configuration

If you leave out the configuration for any of the categories, it will not show the toggle for that category.
That will cause a js error when you attempt to save your settings. It appears that the same error is happening on nole.io
To work around this I am just hiding the unused category with CSS.

Add option to use custom texts in banner, popup etc.

It would be nice if there was an easy way to pass custom texts to the various UI components. Maybe that you could just pass them as options on initialisation. I currently solve this by editing the built JS file, which is not ideal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.