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

Fix video tracking on AB test #3931

Merged
merged 1 commit into from
Jan 22, 2024
Merged

Fix video tracking on AB test #3931

merged 1 commit into from
Jan 22, 2024

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Jan 19, 2024

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What

Fixes video tracking on https://www.gov.uk/self-assessment-ready-reckoner

Note that this appears on the B variant of the A/B test, use the GOVUK browser extension to switch between them or use a mod header extension.

Frontend components should be implemented in templates or helpers, using the code examples found in https://components.publishing.service.gov.uk/component-guide. Injecting pre-rendered component markup into a page like this causes the following problems:

For video tracking and JavaScript in general to work properly on videos they should be wrapped in a govspeak component and rendered in the page template. Pre-rendered markup for components should not be passed through from the locale files.

Why

Video tracking for GA4 was not working on this video.

Visual changes

None.

Trello card: https://trello.com/c/rHlNjPxe/775-video-tracking-not-working-on-a-b-test-pages

@govuk-ci govuk-ci temporarily deployed to govuk-frontend-app-pr-3931 January 19, 2024 15:50 Inactive
@andysellick andysellick marked this pull request as ready for review January 22, 2024 08:57
</div>
<%= render "govuk_publishing_components/components/govspeak", {} do %>
<p><%= t('ab_testing.ready_reckoner_video_description') %></p>
<p><a href="https://www.youtube.com/watch?v=xHn31myAkio">How do I budget for my Self Assessment tax bill?</a></p>
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just wondering if we should put the href and link title in the locale file as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout, will look into.

Copy link
Contributor

@davidtrussler davidtrussler left a comment

Choose a reason for hiding this comment

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

Hi @andysellick - this seems to be a very sensible change. My only concern is to wonder why we didn't do it like that originally so I'd be happier if one of the other requested reviewers could approve it as well in case there's a reason for that which I have missed. 🤔
I would certainly not have expected to implement this in this way more permanently if it was the outcome of the A/B Test.

@andysellick
Copy link
Contributor Author

Hi @andysellick - this seems to be a very sensible change. My only concern is to wonder why we didn't do it like that originally so I'd be happier if one of the other requested reviewers could approve it as well in case there's a reason for that which I have missed. 🤔 I would certainly not have expected to implement this in this way more permanently if it was the outcome of the A/B Test.

Thanks @davidtrussler. I don't know why this was done like this originally, I think on the surface it seems like a reasonable way to do it if you're not familiar with the way our frontend components work. I think it's been a while since we (the frontend team) did any kind of talk about how frontend stuff works to the wider dev community and we're probably overdue.

I'm glad you mentioned this because I've also been asked with fixing a similar problem with this change but that one's a bit more complicated to unravel. Can you take a look?

@davidtrussler
Copy link
Contributor

I'm glad you mentioned this because I've also been asked with fixing a similar problem with this change but that one's a bit more complicated to unravel. Can you take a look?

@andysellick Ah right, so I think on that one there is no other way to do this since the alternate (A/B) content is provided by the translation files by design. I guess that in turn explains why this one was done in a similar way since it followed in the wake of the one you're referring to here (also under some duress over the Xmas period!) We queried this approach with @richardTowers at the time (since embedded videos was a more complex scenario than a simple text change) and it was agreed there was no other way than to approach it like this.

@andysellick
Copy link
Contributor Author

@andysellick Ah right, so I think on that one there is no other way to do this since the alternate (A/B) content is provided by the translation files by design. I guess that in turn explains why this one was done in a similar way since it followed in the wake of the one you're referring to here (also under some duress over the Xmas period!) We queried this approach with @richardTowers at the time (since embedded videos was a more complex scenario than a simple text change) and it was agreed there was no other way than to approach it like this.

Thanks, that's good to know. If it's just a temporary AB test then I'll take a look at seeing if changing the markup in the locale files could make the video tracking work 👍

@andysellick andysellick merged commit c18c771 into main Jan 22, 2024
14 checks passed
@andysellick andysellick deleted the fix-video-tracking branch January 22, 2024 14:04
@richardTowers
Copy link
Contributor

Ah yeah, it was me that asked for it to be done like this originally - sorry about that.

The reasoning was exactly as you suggest - it was a temporary solution, and the ugliness was acceptable in the short term. The longer term plan is to find an elegant way to have this kind of test created in a self-service way by content designers.

I didn't predict the issues with tracking or stylesheet loading though.

To be honest, I'm not sure why I didn't consider using the govspeak component... that seems like a better approach all around. Perhaps I'd suggest putting the whole govspeak block into the locale file though? Rather than splitting it into description / video bits?

andysellick added a commit that referenced this pull request Jan 23, 2024
- move the text and link for the ready reckoner page AB test into the locale files
- forgot to do this as part of a previous PR: #3931
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.

5 participants