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

AB test - replace some content on UTR page #2947

Merged
merged 9 commits into from
Oct 18, 2023

Conversation

richardTowers
Copy link
Contributor

@richardTowers richardTowers commented Oct 5, 2023

https://trello.com/c/jKWA7Nu3/543-ab-test-content-for-find-your-utr-number

HMRC would like to see whether a link to a video performs better than
some descriptive help text. We've agreed to run an AB test to compare
these variants.

There's no elegant way to AB test bits of content in GOV.UK, so we've
had to resort to a workaround where we look for a particular replacement
string in the content (in this case {{ab_test_find_utr_number_video_links}})
and replace it with a value from the translations file, depending on which variant
the user should see.

The code will only be executed on the /find-utr-number page, and only if the placeholder
string appears in the content item's body. This will allow us to deploy this code to production,
and treat the introduction of the placeholder string in the content item as the trigger to
start the test. We can try this out in the draft stack in integration and production before
running it in the live content item.

We think this is a pragmatic thing to do as a one off, as
it keeps an immportant stakeholder happy, helps us learn about video
content (which is a strategic priority), and helps us learn about the
use case for content AB tests in mainstream content.

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 5, 2023 11:13 Inactive
@richardTowers richardTowers force-pushed the ab-test-video-killed-the-utr-star branch from 159f475 to 128cde5 Compare October 5, 2023 11:17
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 5, 2023 11:18 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 6, 2023 09:59 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 6, 2023 10:05 Inactive
@richardTowers richardTowers force-pushed the ab-test-video-killed-the-utr-star branch from 57e7ef7 to 25e5436 Compare October 6, 2023 10:13
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 6, 2023 10:13 Inactive
HMRC would like to see whether a link to a video performs better than
some descriptive help text. We've agreed to run an AB test to compare
these variants.

There's no elegant way to AB test bits of content in GOV.UK, so we've
had to resort to the fragile and ugly approach of find / replacing the
content.

As per the comments in the code, this will break if the content in the
content item changes, and we'll have to update the hardcoded replacement
if the content in the B variant needs to change.

Nevertheless, we think this is a pragmatic thing to do as a one off, as
it keeps an immportant stakeholder happy, helps us learn about video
content (which is a strategic priority), and helps us learn about the
use case for content AB tests in mainstream content.
We don't want to do the replacement in the B variant if the list item on
the page has any text after the link to the HMRC app.

For example, if the list item was

- in the HRMC app which is really good

We would not want the replacement to be

- in the HMRC app - watch a video about finding your UTR number in the app _which is really good_
@richardTowers richardTowers force-pushed the ab-test-video-killed-the-utr-star branch from 25e5436 to 366be79 Compare October 6, 2023 10:17
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 6, 2023 10:17 Inactive
@richardTowers richardTowers changed the title WIP - add AB test for /find-utr-number AB test - replace some content on UTR page Oct 6, 2023
@richardTowers richardTowers marked this pull request as ready for review October 6, 2023 10:18
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 6, 2023 10:25 Inactive
@richardTowers richardTowers marked this pull request as draft October 6, 2023 16:17
@richardTowers
Copy link
Contributor Author

Just popping this back in draft because I'm going on holiday. It's not ready to merge until:

  1. I've worked out which GA dimension to use (currently 300 with a TODO comment)
  2. I've addressed Jess' comments (which are very sensible)

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 09:27 Inactive
As suggested by @hannako, we can make the AB test replacement less
fragile by looking for a specific replacement placeholder in the content
item, instead of replacing a particular bit of content.

I've gone for a [mustache](https://mustache.github.io/) style
replacement string of {{ab_test_find_utr_number_video_links}}. There's a
possible future thought of doing other kinds of templating, so I think
starting to socialise this syntax is a good idea.

I've checked in the govspeak preview app, and the `{{...}}` syntax is ignored
by govspeak so there should be no issue entering it in the publishing
app.

I've pulled the replacement strings out into the translation file so
that they're easier to review / keep up to date.

I've also switched to three A / B / Z variants, so we can do splits like
5% / 5% / 90% where we're measuring the difference between the two 5%
samples and ignoring the 90% sample. This test is probably going to be
50% / 50%, so not strictly necessary, but this seems to be the idiomatic
way to do it.
@richardTowers richardTowers force-pushed the ab-test-video-killed-the-utr-star branch from c3bc3ca to 0f30c12 Compare October 18, 2023 09:28
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 09:28 Inactive
The tests insist on this 😴

I did this quickly in vim, by:

1) Opening all the files with `vim config/locales/*.yml`
2) Copying the YAML fragment to add
3) Pasting it after line 2 in all files by running:

    :argdo execute "normal! 2Gp" | w

4) Making sure the en.yml file only had one set of keys
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 09:44 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 09:54 Inactive
@richardTowers richardTowers force-pushed the ab-test-video-killed-the-utr-star branch from 97e613f to ebf40f7 Compare October 18, 2023 09:56
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 09:56 Inactive
@richardTowers richardTowers marked this pull request as ready for review October 18, 2023 10:21
This isn't required for GA4, but just to make sure our test is
compatible with the older UA code I've picked a custom dimension from
the spreadsheet (linked in a comment).
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 11:24 Inactive
In the situation where this code is deployed, but the content item
doesn't yet contain the placeholder to be replaced, we don't want to do
any of the AB testing code (i.e. setting / reading of cookies, sending
events to google analytics).

This means this code can safely be deployed to production, and the AB
test will only begin once the magic placeholder {{ab_test_find_utr_number_video_links}}
appears in the content item.
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 11:32 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 11:43 Inactive
@richardTowers richardTowers force-pushed the ab-test-video-killed-the-utr-star branch from 6598eb4 to d272c76 Compare October 18, 2023 11:44
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2947 October 18, 2023 11:44 Inactive
Copy link
Contributor

@hannako hannako left a comment

Choose a reason for hiding this comment

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

LGTM!

@richardTowers richardTowers merged commit de26cdc into main Oct 18, 2023
6 checks passed
@richardTowers richardTowers deleted the ab-test-video-killed-the-utr-star branch October 18, 2023 13:56
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