-
Notifications
You must be signed in to change notification settings - Fork 20
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
Update LUX to activate when usage cookies are accepted #2154
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alex-ju
approved these changes
Jun 22, 2021
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.
Excellent work on this, Ian!
if (parsedCookie.usage === true) { | ||
insertScript(scriptSrc) | ||
} else { | ||
window.addEventListener('cookie-consent', function() { |
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.
💯
Merged
injms
force-pushed
the
update-lux-loading-strategy
branch
2 times, most recently
from
July 5, 2021 13:08
88e654a
to
bc60c6f
Compare
Previously LUX was only fired on pages once usage tracking cookies had been accepted - this updates the set up to measure as soon as the page loads, but only sends that information once a user has accepted usage tracking cookies[1]. Information is sent when the event `cookie-consent` is fired, or when the usage cookie has been set to true. The LUX JavaScript files have been renamed to make it a bit clearer what each particular script does. [1]: https://support.speedcurve.com/en/articles/4468508-using-lux-with-cookie-consent-banners
injms
force-pushed
the
update-lux-loading-strategy
branch
from
July 5, 2021 13:30
5ca8dd3
to
e5eef0b
Compare
injms
added a commit
that referenced
this pull request
Jul 5, 2021
Includes: * Update LUX to activate when usage cookies are accepted (#2154)
Merged
injms
added a commit
to alphagov/static
that referenced
this pull request
Jul 5, 2021
This updates the `core_layout` template to match the updates made in the component gem[1], which also needed to be updated at the same time. [1]: alphagov/govuk_publishing_components#2154
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Updates LUX loading strategy to measure (but not report) the page experience of users that haven't yet accepted cookies.
LUX sets a cookie so that users metrics can be seen from page to page - this requires LUX to set a cookie. To ensure that this wasn't tracking users that opted out, both the LUX JavaScript "snippet" and the reporting JavaScript were loaded on the page after a user had accepted cookies.
The LUX snippet is loaded as a JavaScript file as GOV.UK content security policy doesn't allow inline JavaScript. This is loaded first, and measures the user's experience - and then does nothing else.
The
rum-loader.js
checks a users preferences, and will only loadlux-reporter.js
if a user has opted in. If either thecookie-consent
event has been fired or the usage tracking cookie was set, thelux-reporter.js
script is loaded.The
lux-reporter.js
script then sends the measurements off to be analysed; since this JavaScript sets cookies, this file is only loaded if a user has allowed usage cookies.Other changes worth noting:
lux-measurer.js
filelux.js
(usually loaded from Speedcurve's CDN) is in thelux-reporter.js
fileWill help with alphagov/static#2516
Why
This change ensures that the user's privacy preferences are respected and the crucial first page load on a cold cache can be accurately reported.
Visual Changes
None