Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Add analytics to the accounts manager #241

Merged
merged 6 commits into from
Oct 27, 2020
Merged

Add analytics to the accounts manager #241

merged 6 commits into from
Oct 27, 2020

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Oct 22, 2020

What

Add analytics code to the accounts manager.

Depends upon alphagov/govuk_publishing_components#1745 and alphagov/govuk_publishing_components#1751 for the analytics code, so won't work until that PR is merged and we have a new version of the gem with it installed in the accounts manager. This is making the tests fail as well.

The latest commit on this PR demonstrates how to use the track click script in PR 1751 to fire a tracking event on the user create/enter email screen's 'continue' button. This is an initial test of the use of this, which will be done much more widely.

Why

We want to ask users for their consent to be tracked so that we can understand how users interact with accounts.

Visual changes

None, but it's worth explaining how this page works so it's clear and we can iterate it if necessary.

Screenshot 2020-10-22 at 16 57 36

If the user selects 'yes' to cookies, the analytics code is initialised and a tracking event (pageview) is fired. If the user selects 'no' nothing happens, unless there's already a cookie, in which case it gets deleted. This might not be the best solution long term, but we can iterate it.

Trello card: https://trello.com/c/2gMj38xR/330-build-analytics

@andysellick andysellick changed the title Add analytics to the accounts manager [DO NOT MERGE] Add analytics to the accounts manager Oct 22, 2020
@andysellick andysellick marked this pull request as ready for review October 22, 2020 16:08
@alex-ju alex-ju changed the title [DO NOT MERGE] Add analytics to the accounts manager Add analytics to the accounts manager Oct 27, 2020
andysellick and others added 5 commits October 27, 2020 13:31
- need to include google analytics domain because initialising GA involves a call to append a new script onto the DOM and run it
- note that this change depends upon analytics code being in the components gem, which at time of writing is not complete
- analytics code is initialised on every page, if a previously set consent cookie is found, pageviews are sent
- the registration flow includes a yes/no radio for cookie consent, choosing 'yes' sets the cookie and immediately reinitialises the analytics code, firing a pageview
- if the user chooses 'no' that cookie is deleted
- this preference is not currently tied to the record in the user profile although this may change
@alex-ju
Copy link
Contributor

alex-ju commented Oct 27, 2020

I took this over from Andy, rebased the work, and resolved conflicts then I addressed the 'Create an account' section of our analytics request which required us to:

Screenshot 2020-10-27 at 13 08 03

  • Track actions on 'Confirm your email address' page a66a639.

I would be keen to address the remaining sections 'Account' and 'Going back' in a separate PR to avoid falling behind with this one as we are changing the views rather quickly these days.

config/locales/en.yml Outdated Show resolved Hide resolved
It is unfortunate that we have to add these in the yml, but I don't see an alternative without taking the time to extract the markup and move it to the views.
@alex-ju alex-ju merged commit 50f58f4 into main Oct 27, 2020
@alex-ju alex-ju deleted the use-analytics branch October 27, 2020 13:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants