diff --git a/src/experiments/ab-tests.ts b/src/experiments/ab-tests.ts index 84edbfad2..7702fe68d 100644 --- a/src/experiments/ab-tests.ts +++ b/src/experiments/ab-tests.ts @@ -2,6 +2,7 @@ import type { ABTest } from '@guardian/ab-core'; import { gpidPrebidAdUnits } from './tests/gpid-prebid'; import { mpuWhenNoEpic } from './tests/mpu-when-no-epic'; import { optOutFrequencyCap } from './tests/opt-out-frequency-cap'; +import { prebidKeywords } from './tests/prebid-keywords'; import { regionSpecificPrebid } from './tests/region-specific-prebid'; /** @@ -15,4 +16,5 @@ export const concurrentTests: ABTest[] = [ optOutFrequencyCap, gpidPrebidAdUnits, regionSpecificPrebid, + prebidKeywords, ]; diff --git a/src/experiments/tests/prebid-keywords.ts b/src/experiments/tests/prebid-keywords.ts new file mode 100644 index 000000000..442f664b2 --- /dev/null +++ b/src/experiments/tests/prebid-keywords.ts @@ -0,0 +1,29 @@ +import type { ABTest } from '@guardian/ab-core'; + +export const prebidKeywords: ABTest = { + id: 'PrebidKeywords', + author: '@commercial-dev', + start: '2025-01-14', + expiry: '2025-01-31', + audience: 50 / 100, + audienceOffset: 20 / 100, + audienceCriteria: '', + successMeasure: '', + description: + 'Test if adding keywords to our Prebid config affects revenue.', + variants: [ + { + id: 'control', + test: (): void => { + /* no-op */ + }, + }, + { + id: 'variant', + test: (): void => { + /* no-op */ + }, + }, + ], + canRun: () => true, +}; diff --git a/src/lib/header-bidding/prebid/prebid.ts b/src/lib/header-bidding/prebid/prebid.ts index b88eb535d..7a082f432 100644 --- a/src/lib/header-bidding/prebid/prebid.ts +++ b/src/lib/header-bidding/prebid/prebid.ts @@ -10,6 +10,7 @@ import type { PageTargeting } from '../../../core/targeting/build-page-targeting import type { Advert } from '../../../define/Advert'; import { getParticipations, isUserInVariant } from '../../../experiments/ab'; import { gpidPrebidAdUnits } from '../../../experiments/tests/gpid-prebid'; +import { prebidKeywords } from '../../../experiments/tests/prebid-keywords'; import { getAdvertById } from '../../dfp/get-advert-by-id'; import { isUserLoggedInOktaRefactor } from '../../identity/api'; import { getPageTargeting } from '../../page-targeting'; @@ -88,6 +89,11 @@ type PbjsConfig = { timeoutBuffer?: number; priceGranularity: PrebidPriceGranularity; userSync: UserSync; + ortb2?: { + site: { + keywords: string; + }; + }; consentManagement?: ConsentManagement; realTimeData?: unknown; criteo?: { @@ -364,6 +370,17 @@ const initialise = ( }, ); + const shouldIncludeKeywords = isUserInVariant(prebidKeywords, 'variant'); + const keywords = window.guardian.config.page.keywords; + + if (shouldIncludeKeywords) { + pbjsConfig.ortb2 = { + site: { + keywords, + }, + }; + } + window.pbjs.bidderSettings = {}; if (window.guardian.config.switches.consentManagement) {