-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow configuring postcode pii stripping in analytics via meta tag #1183
Allow configuring postcode pii stripping in analytics via meta tag #1183
Conversation
cfc2225
to
4dadb01
Compare
Is this still relevant @h-lame? The tests aren't passing |
@boffbowsh It's been a while, but I think the tests on this won't pass until alphagov/govuk_frontend_toolkit#435 is merged, released, and that version included in our Gemfile. |
@h-lame Can you rebase this please and I'll have a proper look? |
For review purposes, look at the last 2 commits only:
I've extracted the rest to their own PR as they're useful regardless of this one. I will rebase this one on top of that once it's merged to master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MWG 👍
Stripping PII is a function provided by the GOVUK.Analytics module from govuk_frontend_toolkit in version 7.3.0 which we upgrade to in this commit. By default it strips emails from all arguments passed to GA, but it can also strip Postcodes if you tell it to. It doesn't do postcodes by default because they're much more likely to cause false positives. There's no easy way for apps using static to run some code before analytics/init.js is run to let them pass arguments or configure the object before the initial trackPageVie is called, so we look for the presence of a meta-tag called "govuk:static-analytics:strip-postcodes". If it's there, we will tell GOVUK.Analytics to strip postcodes, if it's not we will tell it not to. It doesn't matter what the content of the meta-tag is, just if it's there or not.
4dadb01
to
1e91f7e
Compare
Smart Answers and search pages are the formats where we are likely to have postcodes in the GA data. Smart Answers because some of them have a postcode entry question that forms part of the URL, and search because we see people searching for their postcodes fairly regularly. Unfortunately this approach is hampered by the fact that smartanswers report the wrong format at the moment. Smart answers are split into two documents; the start-page at `/slug` which is a `transaction` and rendered by frontend, and the interactive Q&A part at `/slug/y` which is a `smart_answer` and rendred by smart-answers. Unfortuntately smart-answers loads the `/slug` content item, not the `/slug/y` content item so it reports the format as transaction, not smart_answer. Until this is fixed we want to be able to explicitly say in smartanswers that we should strip postcodes, so we allow a `strip_postcode_pii` option to be provided to the component that will always add the meta tag, regardless of the document_type of the content_item. This may come in useful for other one off pages where we need to strip postcodes.
1e91f7e
to
8dd78fc
Compare
For: https://trello.com/c/ilkmeS5E/239-investigate-preventing-pii-being-sent-to-ga
This relies on the changes in alphagov/govuk_frontend_toolkit#435 so will need a gemfile bump once that is released. Our goal here is to make sure we strip PII from all GA data, by default
GOVUK.Analytics
will strip emails, but can be configured to also strip postcodes. The changes to static make it possible to set that config via a meta tag. We also add that meta-tag by default if your app is using the analytics_meta_tag component and the content is in a format where we expect postcode data (smart_answer
orsearch
at the moment) might be present. We also allow passing an argument to the component to turn postcode stripping on or off regardless of the content format.This is best reviewed commit-by-commit as the early commits concern themselves with tidying up and re-organising the tests for static-analytics to pave the way for these changes.