alphagov / govuk-frontend-docs

Technical documentation for GOV.UK Frontend
https://frontend.design-system.service.gov.uk/
35 stars 11 forks source link

Add cookie banner to frontend docs #134

Open vanitabarrett opened 3 years ago

vanitabarrett commented 3 years ago

What

Add the cookie banner component to all pages in the design system. Hook into the cookie consent functions so that users can accept or reject cookies

This is likely to look different to https://github.com/alphagov/govuk-design-system/issues/1618 as the frontend docs uses the tech docs template. We should look into if it's possible to add functionality to the tech docs template to display a cookie banner without having to inject it using JavaScript.

Why

We need to give users the choice to accept or reject cookies.

Who needs to know about this

Developers

Done when

owenatgov commented 2 months ago

It now makes sense to do this across the design system and frontend docs as we've figured out as part of https://github.com/alphagov/govuk-design-system/issues/1613 that we can do cross domain cookie consent.

From investigation, doing this poses some tricky technical problems, mostly around the context of this being the tech docs gem.

If we don't want to do cross domain tracking, we have to either inject the cookie banner via js or rebuild the core template in the tech docs gem so that we can include the cookie banner like we do in the design system. Injecting via js will involve some potentially quite heavy js and rewriting the core template runs the risk of becoming out of sync with the upstream version of core. Both of these mean we have to find a way to remember ot stay up to date with changes to the cookie banner.

If we do want to do cross domain tracking, we'd need a way for our analytics code to stay up to date between domains. Pay do this using their own separate package: Pay JS Commons, which includes their analytics and cookie consent code. It would be an extra thing for us to maintain but theoretically small and conveneient. It also includes injection of the cookie banner via js, which we'd ideally want to avoid.

There was some work done a while ago to try and add the cookie banner as a configurable element in the tech docs gem but it fell through. We could potentially pick this up again and release a new version of the gem. The risk here is that we also need a way to keep the cookie banner in the tech docs gem up to date as well, especially since the tech docs gem is a rails project.