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

Do not track users who have enabled 'DoNotTrack' #521

Merged
merged 2 commits into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
New features:

- [#501 Add default session data](https://github.com/alphagov/govuk_prototype_kit/pull/501)
- [#502 Add Cookies and Privacy policy text](https://github.com/alphagov/govuk_prototype_kit/pull/502)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't look like it belongs in this PR

Copy link
Contributor Author

@NickColley NickColley Jun 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm cleaning up the fact there's two 'new features' sections in the unreleased section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right its moved not an addition, ok

- [#521 Do not track users who have enabled 'DoNotTrack'](https://github.com/alphagov/govuk_prototype_kit/pull/521)

Bug fixes:

- [#491 Remove redundant Google Analytics](https://github.com/alphagov/govuk_prototype_kit/pull/491)

New features:
- [#502 Add Cookies and Privacy policy text](https://github.com/alphagov/govuk_prototype_kit/pull/502)

# 6.3.0

New features:
Expand Down
4 changes: 2 additions & 2 deletions docs/views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

{% block head %}
{% include "includes/head.html" %}
{% if promoMode == 'true' and gtmId %}
{% if doNotTrackEnabled == false and promoMode == 'true' and gtmId %}
{% include "includes/tracking_head.html" %}
{% endif %}
{% endblock %}


{% block bodyStart %}
{% if promoMode == 'true' and gtmId %}
{% if doNotTrackEnabled == false and promoMode == 'true' and gtmId %}
{% include "includes/tracking_body.html" %}
{% endif %}
{% endblock %}
Expand Down
9 changes: 9 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ app.use(bodyParser.urlencoded({
extended: true
}))

// Add global variable to determine if DoNotTrack is enabled.
// This indicates a user has explicitly opted-out of tracking.
// Therefore we can avoid injecting third-party scripts that do not respect this decision.
app.use(function (req, res, next) {
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/DNT
app.locals.doNotTrackEnabled = (req.header('DNT') === '1')
next()
})

// Add variables that are available in all views
app.locals.gtmId = gtmId
app.locals.asset_path = '/public/'
Expand Down