Alex-D / Cookies-EU-banner

1kb vanilla JS script which manages cookies consent banner display like asked by GDPR
http://alex-d.github.io/Cookies-EU-banner/
MIT License
439 stars 57 forks source link

Cookies-EU-banner dissapears on reload of page #15

Closed vrghost242 closed 8 years ago

vrghost242 commented 9 years ago

Love this solution, simple, straight forward and seems to work well.

However, I found what I think is a bug. If you load the page it comes up perfectly, but if I then do a refresh on the page, the banner does not load, not certain if from a regulatory point of view this would meet the requirements. I changed the code to set the "true" option for wait as below, but still same behaviour:

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', '<%= trackingID %>', 'auto');
    ga('require', 'linkid', 'linkid.js');
    ga('send', 'pageview');
}), true;

Of course, if it is that regulations wise, its ok that it disappears after refresh I am happy to keep it the way it currently is.

vrghost242 commented 9 years ago

OK, looking at the regs, I think I actually wan't it to work this way. Turns out that (as far as I can tell) there implied consent is enough, so a warning seems to be enough, or at least some rather large companies lawyers seems to think so:)

Alex-D commented 9 years ago

You've got a typo, try that :

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', '<%= trackingID %>', 'auto');
    ga('require', 'linkid', 'linkid.js');
    ga('send', 'pageview');
}, true);

The wrong part is that : }), true; which become }, true);