Skip to content
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

Conversation

h-lame
Copy link
Contributor

@h-lame h-lame commented Nov 2, 2017

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 or search 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.

@fofr fofr temporarily deployed to govuk-static-pr-1183 November 2, 2017 17:39 Inactive
@h-lame h-lame force-pushed the allow-configuring-postcode-pii-stripping-in-analytics-via-meta-tag branch from cfc2225 to 4dadb01 Compare November 14, 2017 14:53
@boffbowsh
Copy link
Contributor

Is this still relevant @h-lame? The tests aren't passing

@h-lame
Copy link
Contributor Author

h-lame commented Jan 15, 2018

@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.

@boffbowsh
Copy link
Contributor

@h-lame Can you rebase this please and I'll have a proper look?

@h-lame
Copy link
Contributor Author

h-lame commented Feb 8, 2018

For review purposes, look at the last 2 commits only:

  • Allow configuring stripping postcode PII in analytics via a meta-tag
  • Always add the strip-postcodes meta tag for some content items

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.

Copy link
Contributor

@boffbowsh boffbowsh left a 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.
@h-lame h-lame force-pushed the allow-configuring-postcode-pii-stripping-in-analytics-via-meta-tag branch from 4dadb01 to 1e91f7e Compare February 8, 2018 16:05
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.
@h-lame h-lame force-pushed the allow-configuring-postcode-pii-stripping-in-analytics-via-meta-tag branch from 1e91f7e to 8dd78fc Compare February 8, 2018 16:16
@h-lame h-lame merged commit 4a842fd into master Feb 9, 2018
@h-lame h-lame deleted the allow-configuring-postcode-pii-stripping-in-analytics-via-meta-tag branch February 9, 2018 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants