docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

feat(gtag): cookie consent banner

Open Josh-Cena opened this issue 3 years ago ā€¢ 13 comments

Motivation

Fix #2407.

The current approach doesn't look clean enough because we need to check local storage on every route transition, but otherwise, the tracking only starts after the user refreshed and the site reloads with the new local storage value.

Waiting to polish the banner design.

We can port this banner to google analytics after merging this one, or before it's ready to be merged.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Temporarily enabled the plugin in deploy preview to make it show up

Josh-Cena avatar Jan 16 '22 09:01 Josh-Cena

āœ”ļø [V2]

šŸ”Ø Explore the source changes: 543b5df52bfa198208ac66263e325ea2d2172653

šŸ” Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61e410cff398830008fbe71d

šŸ˜Ž Browse the preview: https://deploy-preview-6376--docusaurus-2.netlify.app

netlify[bot] avatar Jan 16 '22 09:01 netlify[bot]

āš”ļø Lighthouse report for the changes in this PR:

Category Score
šŸŸ  Performance 68
šŸŸ¢ Accessibility 98
šŸŸ¢ Best practices 93
šŸŸ¢ SEO 100
šŸŸ¢ PWA 92

Lighthouse ran on https://deploy-preview-6376--docusaurus-2.netlify.app/

github-actions[bot] avatar Jan 16 '22 09:01 github-actions[bot]

Size Change: +1.8 kB (0%)

Total Size: 680 kB

Filename Size Change
website/build/assets/css/styles.********.css 103 kB +545 B (+1%)
website/build/assets/js/main.********.js 504 kB +1.25 kB (0%)
ā„¹ļø View Unchanged
Filename Size
website/.docusaurus/globalData.json 42.9 kB
website/build/index.html 29.6 kB

compressed-size-action

github-actions[bot] avatar Jan 16 '22 09:01 github-actions[bot]

I have an internal Meta doc (that I cannot share) and it seems blocking gtag is not enough.

We also need to be able to block localStorage usage, including in core/theme (ie no announcementBar dismiss or theme persistence)

And we need to think about this with a long-term vision: if the user needs 2 plugins requiring localstorage/tracking, only one consent banner should be presented, probably with granular options (checkboxes) and i18n messages.


Maybe this PR is a good-enough first step and we can improve later, will ask.

slorber avatar Jan 19 '22 11:01 slorber

We also need to be able to block localStorage usage, including in core/theme (ie no announcementBar dismiss or theme persistence)

Really...? Everywhere I checked, our moderate usage of localStorage is permitted. GDPR doesn't forbid local storage as long as it's for the interest of the user (e.g. not annoying them by showing the announcement every time)

Josh-Cena avatar Jan 19 '22 11:01 Josh-Cena

Really...? Everywhere I checked, our moderate usage of localStorage is permitted. GDPR doesn't forbid local storage as long as it's for the interest of the user (e.g. not annoying them by showing the announcement every time)

hmm yes I found this surprising too

Re-reading that internal doc, I'll try to clarify this part.

It's not 100% clear what should be the behavior when localStorage is used but without any purpose of tracking users

slorber avatar Jan 19 '22 12:01 slorber

It's hard to read between the lines between all the online resources, but I think it's fine to use localStorage for non-tracking functional behavior after user-interactions.

Something we should refactor: we shouldn't set default values in localStorage when the user is just landing on a page. Values must only be set after interactions that require such storage usage.

Apparently, we'd still need to disclose to the user that storage is used šŸ¤·ā€ā™‚ļø https://www.reddit.com/r/gdpr/comments/s7sk3w/localstorage_to_persist_dark_mode_theme/

slorber avatar Jan 20 '22 16:01 slorber

šŸ› Bug: image image

PatelN123 avatar Jan 30 '22 11:01 PatelN123

Is this still worked on? Happy to help as we need to be GDPR compliant ;)

JohannesDienst-askui avatar Sep 29 '22 11:09 JohannesDienst-askui

Do you speak Spanish? Iā€™m new on this can you please help me

On Thu, Sep 29, 2022 at 6:53 AM Johannes Dienst @.***> wrote:

Is this still worked on? Happy to help as we need to be GDPR compliant ;)

ā€” Reply to this email directly, view it on GitHub https://github.com/facebook/docusaurus/pull/6376#issuecomment-1262169554, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2UJ54Q65OVTXBWBDIJJKV3WAV7MNANCNFSM5MCQZFPQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Nanin22 avatar Sep 29 '22 11:09 Nanin22

Hi. Do we have plans to merge this sooner? Thanks

monica-m-ps avatar Oct 13 '22 12:10 monica-m-ps

I'm also interested on this kind of feature.

0ptim avatar Oct 25 '22 19:10 0ptim

@Josh-Cena is this feature planned to be continued and merged any time soon? Adding Google Analytics via the gtag definitely requires GDPR consent and doing it right feels like a significant effort on our side. Having that built-in would be of great help.

wgruszczyk avatar Nov 25 '22 13:11 wgruszczyk

Hi, any news on this?

Cookie consent is a basic requirement from GDPR

Shnitselon avatar Mar 27 '23 08:03 Shnitselon

@Shnitselon I decided to go with https://github.com/Mastermindzh/react-cookie-consent, maybe not ideal and ootb, but definitely sufficient to satisfy GDPR requirements.

wgruszczyk avatar Mar 27 '23 11:03 wgruszczyk

Hello. Any update on this?

monica-m-ps avatar Jan 06 '24 01:01 monica-m-ps

Sorry everyone who commented under this. I will not be working on this for any foreseeable future because we don't know what needs to be done.

Please comment under the linked issue detailing what you think (or better, what you know, backed by actual laws) the consent banner should do:

  1. Does it need to block all local storage access (including persisting the color mode choice, tab choice, etc.)?
  2. Does it need to stop sending Google analytics? If so, at which stage (not loading the script tag at all, or just not sending the page view events)? Or is there a way to send analytics in a "private mode" that does not rely on user data?
  3. Do you use other plugins that require this privacy protection too? Do they currently handle privacy issues? If so, what mechanism do they use?
  4. Any other feature you use on your site that requires cookie consent?

Thank you.

Josh-Cena avatar Jan 06 '24 07:01 Josh-Cena

  1. https://github.com/68publishers/cookie-consent - if all you need is add a Cookie Consent for Google Tags - this works out of the box with Docusaurus gtag plugin - without installing anything extra on your site

  2. https://cookieconsent.orestbida.com/ - this one seems to be more flexible. Needs to be installed on your site.

oyatek avatar May 09 '24 01:05 oyatek