From 5467dba40b4be06d7bceb85b072e7d7f1792c4ff Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Fri, 15 Mar 2024 14:18:45 +0000 Subject: [PATCH 1/5] Add AB test --- common/app/conf/switches/ABTestSwitches.scala | 10 +++++++ .../common/modules/experiments/ab-tests.ts | 2 ++ ...block-supporter-revenue-messaging-sport.ts | 29 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts diff --git a/common/app/conf/switches/ABTestSwitches.scala b/common/app/conf/switches/ABTestSwitches.scala index 980e5b0eb490..c66c5bdb9124 100644 --- a/common/app/conf/switches/ABTestSwitches.scala +++ b/common/app/conf/switches/ABTestSwitches.scala @@ -64,4 +64,14 @@ trait ABTestSwitches { sellByDate = Some(LocalDate.of(2024, 4, 2)), exposeClientSide = true, ) + + Switch( + ABTests, + "ab-block-supporter-revenue-messaging-sport", + "Block supporter revenue messaging in the Sport section", + owners = Seq(Owner.withEmail("commercial.dev@theguardian.com")), + safeState = Off, + sellByDate = Some(LocalDate.of(2024, 6, 1)), + exposeClientSide = true, + ) } diff --git a/static/src/javascripts/projects/common/modules/experiments/ab-tests.ts b/static/src/javascripts/projects/common/modules/experiments/ab-tests.ts index df0ecca8fa3e..381e66df4b4c 100644 --- a/static/src/javascripts/projects/common/modules/experiments/ab-tests.ts +++ b/static/src/javascripts/projects/common/modules/experiments/ab-tests.ts @@ -1,4 +1,5 @@ import type { ABTest } from '@guardian/ab-core'; +import { blockSupporterRevenueMessagingSport } from './tests/block-supporter-revenue-messaging-sport'; import { mpuWhenNoEpic } from './tests/mpu-when-no-epic'; import { oscarsNewsletterEmbed } from './tests/oscars-newsletter-embed'; import { remoteRRHeaderLinksTest } from './tests/remote-header-test'; @@ -17,4 +18,5 @@ export const concurrentTests: readonly ABTest[] = [ mpuWhenNoEpic, sectionAdDensity, oscarsNewsletterEmbed, + blockSupporterRevenueMessagingSport, ]; diff --git a/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts b/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts new file mode 100644 index 000000000000..043bab2415a5 --- /dev/null +++ b/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts @@ -0,0 +1,29 @@ +import type { ABTest } from '@guardian/ab-core'; + +export const blockSupporterRevenueMessagingSport: ABTest = { + id: 'BlockSupporterRevenueMessagingSport', + author: '@commercial-dev', + start: '2024-03-14', + expiry: '2024-06-01', + audience: 0 / 100, + audienceOffset: 0 / 100, + audienceCriteria: 'Fronts and articles in the Sport section', + successMeasure: + 'Ad revenue and ad ration increases without significantly impacting supporter revenue', + description: 'Block supporter revenue messaging in the Sport section', + variants: [ + { + id: 'control', + test: (): void => { + /* no-op */ + }, + }, + { + id: 'variant', + test: (): void => { + /* no-op */ + }, + }, + ], + canRun: () => true, +}; From dc301b9461f7d7634e8425be421c54adc77040ee Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Fri, 15 Mar 2024 15:35:09 +0000 Subject: [PATCH 2/5] Change expiry date --- common/app/conf/switches/ABTestSwitches.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/app/conf/switches/ABTestSwitches.scala b/common/app/conf/switches/ABTestSwitches.scala index c66c5bdb9124..9f81705961e8 100644 --- a/common/app/conf/switches/ABTestSwitches.scala +++ b/common/app/conf/switches/ABTestSwitches.scala @@ -71,7 +71,7 @@ trait ABTestSwitches { "Block supporter revenue messaging in the Sport section", owners = Seq(Owner.withEmail("commercial.dev@theguardian.com")), safeState = Off, - sellByDate = Some(LocalDate.of(2024, 6, 1)), + sellByDate = Some(LocalDate.of(2024, 5, 31)), exposeClientSide = true, ) } From 8c1cd863b7237a7043277df4e3937b26db6b5a96 Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Wed, 20 Mar 2024 10:54:24 +0000 Subject: [PATCH 3/5] Hide banner for test participants in the sport and football section --- .../projects/common/modules/support/banner.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/src/javascripts/projects/common/modules/support/banner.ts b/static/src/javascripts/projects/common/modules/support/banner.ts index 243ba2b7a42e..75766e6bb211 100644 --- a/static/src/javascripts/projects/common/modules/support/banner.ts +++ b/static/src/javascripts/projects/common/modules/support/banner.ts @@ -34,6 +34,8 @@ import userPrefs from 'common/modules/user-prefs'; import fastdom from 'lib/fastdom-promise'; import { getCountryCode } from 'lib/geolocation'; import { reportError } from 'lib/report-error'; +import { isInVariantSynchronous } from '../experiments/ab'; +import { blockSupporterRevenueMessagingSport } from '../experiments/tests/block-supporter-revenue-messaging-sport'; export const NO_RR_BANNER_TIMESTAMP_KEY = 'gu.noRRBannerTimestamp'; // timestamp of when we were last told not to show a RR banner const twentyMins = 20 * 60_000; @@ -165,11 +167,19 @@ export const fetchBannerData = async (): Promise => { const purchaseInfo = getPurchaseInfo(); const isSignedIn = await isUserLoggedIn(); const payload = await buildBannerPayload(purchaseInfo, isSignedIn); + const shouldHideBannerForTest = + isInVariantSynchronous( + blockSupporterRevenueMessagingSport, + 'variant', + ) && + (payload.targeting.sectionId === 'sport' || + payload.targeting.sectionId === 'football'); if ( payload.targeting.shouldHideReaderRevenue || payload.targeting.isPaidContent || - isHosted + isHosted || + shouldHideBannerForTest ) { return Promise.resolve(null); } From 794622dc877b0c5988fce3dfe3f59db46eac95c9 Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Wed, 20 Mar 2024 16:46:22 +0000 Subject: [PATCH 4/5] Add a canRun --- .../tests/block-supporter-revenue-messaging-sport.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts b/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts index 043bab2415a5..741ce9ed16e4 100644 --- a/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts +++ b/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts @@ -25,5 +25,7 @@ export const blockSupporterRevenueMessagingSport: ABTest = { }, }, ], - canRun: () => true, + canRun: () => + window.guardian.config.page.section === 'sport' || + window.guardian.config.page.section === 'football', }; From c6fe6f087be73976f2cd4b78055a98d63fe9c92c Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Thu, 21 Mar 2024 12:20:11 +0000 Subject: [PATCH 5/5] Typo --- .../tests/block-supporter-revenue-messaging-sport.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts b/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts index 741ce9ed16e4..6550799e814f 100644 --- a/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts +++ b/static/src/javascripts/projects/common/modules/experiments/tests/block-supporter-revenue-messaging-sport.ts @@ -9,7 +9,7 @@ export const blockSupporterRevenueMessagingSport: ABTest = { audienceOffset: 0 / 100, audienceCriteria: 'Fronts and articles in the Sport section', successMeasure: - 'Ad revenue and ad ration increases without significantly impacting supporter revenue', + 'Ad revenue and ad ratio increases without significantly impacting supporter revenue', description: 'Block supporter revenue messaging in the Sport section', variants: [ {