rstudio / distill

Distill for R Markdown
https://rstudio.github.io/distill/
Apache License 2.0
423 stars 57 forks source link

GDPR compliance: Cookie consent form #220

Closed ADernild closed 3 years ago

ADernild commented 3 years ago

From my understanding of GDPR setting tracking cookies, e.g., Google Analytics, requires informed consent to do so, for any user residing in the EU. Therefore, I would like to request a feature, where a cookie consent form/pop-up can be implemented easily, i.e., through _site.yml. Also if anyone knows how to easily implement an opt-in cookie consent form in other ways e.g., html injection, please do let me know! :)

apreshill commented 3 years ago

Thanks for bringing this up. I know my personal Hugo site has this option, leaving some links here for us to investigate more:

https://github.com/wowchemy/wowchemy-hugo-modules/issues/507 https://gohugo.io/about/hugo-and-gdpr/

ADernild commented 3 years ago

Thanks for the links! I have now taken a deeper dive into the distill for R markdown repository files and from what I can tell it's the function site_header_extras(site_config) in site_includes.R, that sets the gtag (Google Analytics cookie). I'm going to try and add a cookie consent pop-up generator to this function tomorrow and rebuild the package. I have played a bit around with www.cookieconsent.com now and it seems pretty straight forward to set up. I'll let you know how it goes :)

ADernild commented 3 years ago

I have successfully created the option of adding a cookieconsent.com banner through _site.yml, however, currently it can only toggle the Google Analytics cookie and I think disqus uses a cookie as well (not sure though, as I don't use disqus). I have opened a pull request #223 with my changes, any feedback or ideas for improvement is much appreciated.

cookieconsent.com banner can be manipulated through the _site.yml with the tags:

cookie_consent:
    style: simple/headline/interstitial/standalone
    type: express/implied
    palette: light/dark
    lang: en/de/fr/es/ca_es/it/nl/pt/fi/hu/cs/hr/da/sl/pl/ro/sr/bg/cy
    privacy_policy: link to privacy policy