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

Persist landing page test tracking #6381

Merged
merged 5 commits into from
Oct 22, 2024
Merged

Persist landing page test tracking #6381

merged 5 commits into from
Oct 22, 2024

Conversation

tomrf1
Copy link
Member

@tomrf1 tomrf1 commented Oct 7, 2024

Currently, if an AB test is targeted specifically at the landing page then the tracking doesn't carry through to the checkout. This means it doesn't get included in the acquisition event.

This PR fixes this by changing the landing page to add the AB test participations to session storage.
Subsequent pages will then pick up participations from session storage.
This is limited by the new persistPage field on the AB test model. A page will only pick up participations from session storage if persistPage matches the current path.

Copy link
Contributor

github-actions bot commented Oct 7, 2024

Size Change: +1.71 kB (+0.07%)

Total Size: 2.29 MB

ℹ️ View Unchanged
Filename Size Change
./public/compiled-assets/javascripts/[countryGroupId]/events/router.js 112 kB +104 B (+0.09%)
./public/compiled-assets/javascripts/[countryGroupId]/router.js 258 kB +91 B (+0.04%)
./public/compiled-assets/javascripts/ausMomentMap.js 108 kB -1 B (0%)
./public/compiled-assets/javascripts/contributionsRedirectStyles.js 20 B 0 B
./public/compiled-assets/javascripts/digitalSubscriptionLandingPage.js 242 kB +109 B (+0.05%)
./public/compiled-assets/javascripts/downForMaintenancePage.js 69.2 kB +103 B (+0.15%)
./public/compiled-assets/javascripts/error404Page.js 69.2 kB +101 B (+0.15%)
./public/compiled-assets/javascripts/error500Page.js 69.1 kB +102 B (+0.15%)
./public/compiled-assets/javascripts/favicons.js 617 B 0 B
./public/compiled-assets/javascripts/paperSubscriptionCheckoutPage.js 195 kB +102 B (+0.05%)
./public/compiled-assets/javascripts/paperSubscriptionLandingPage.js 85.7 kB +92 B (+0.11%)
./public/compiled-assets/javascripts/payPalErrorPage.js 67.5 kB +112 B (+0.17%)
./public/compiled-assets/javascripts/payPalErrorPageStyles.js 20 B 0 B
./public/compiled-assets/javascripts/promotionTerms.js 72.1 kB +99 B (+0.14%)
./public/compiled-assets/javascripts/subscriptionsLandingPage.js 71.3 kB +101 B (+0.14%)
./public/compiled-assets/javascripts/subscriptionsRedemptionPage.js 126 kB +98 B (+0.08%)
./public/compiled-assets/javascripts/supporterPlusLandingPage.js 311 kB +184 B (+0.06%)
./public/compiled-assets/javascripts/unsupportedBrowserStyles.js 20 B 0 B
./public/compiled-assets/javascripts/weeklySubscriptionCheckoutPage.js 192 kB +100 B (+0.05%)
./public/compiled-assets/javascripts/weeklySubscriptionLandingPage.js 85.6 kB +111 B (+0.13%)
./public/compiled-assets/webpack/136.js 2.17 kB 0 B
./public/compiled-assets/webpack/187.js 21.4 kB +105 B (+0.49%)
./public/compiled-assets/webpack/344.js 2.01 kB 0 B
./public/compiled-assets/webpack/671.js 21.8 kB 0 B
./public/compiled-assets/webpack/706.js 107 kB 0 B

compressed-size-action

@rupertbates
Copy link
Member

Why would we not just target the landing page and checkout page?

@tomrf1
Copy link
Member Author

tomrf1 commented Oct 7, 2024

Why would we not just target the landing page and checkout page?

we don't want people who go straight to checkout to be included in the test - they must go via the landing page. We're sending quite a lot of users straight to checkout now. The existing setup for AB test targeting doesn't really support the 2-step flow correctly

@@ -120,6 +122,7 @@ function init({
const urlParticipations = getParticipationsFromUrl();
const serverSideParticipations = getServerSideParticipations();
return {
...sessionParticipations,
Copy link
Contributor

Choose a reason for hiding this comment

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

sessionParticipations could be undefined, can you use a spread operator on undefined? I would've expected TS to complain here 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. It appears you can spread on undefined - and here serverSideParticipations and urlParticipations are also potentially undefined.
I guess we could be a bit more deliberate about it with ...(sessionParticipations ?? {})

Copy link
Contributor

@GHaberis GHaberis left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@tomrf1 tomrf1 marked this pull request as ready for review October 15, 2024 12:47
@tomrf1
Copy link
Member Author

tomrf1 commented Oct 15, 2024

DP have approved the use of the session storage item

@GHaberis
Copy link
Contributor

DP have approved the use of the session storage item

Excellent, this looks good to go for me then

@@ -154,8 +163,10 @@ function getParticipations(
mvtId: number,
country: IsoCountry,
countryGroupId: CountryGroupId,
path: string,
Copy link
Member Author

Choose a reason for hiding this comment

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

To make this function easier to test, we now pass in a path instead of using window.location.pathname directly

Copy link
Member

@rupertbates rupertbates left a comment

Choose a reason for hiding this comment

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

This is really nice, well done for providing tests 👍

@tomrf1 tomrf1 merged commit 6d27e46 into main Oct 22, 2024
18 checks passed
@tomrf1 tomrf1 deleted the tf-lp-ab-tests branch October 22, 2024 07:02
@prout-bot
Copy link

Seen on PROD (merged by @tomrf1 12 minutes and 11 seconds ago)

Sentry Release: support-client-side, support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants