Skip to content

Commit

Permalink
Add keywords to pbjsConfig if user is in the prebidKeywords test (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-imber authored Jan 15, 2025
1 parent e18c29a commit 758d47c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/experiments/ab-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -15,4 +16,5 @@ export const concurrentTests: ABTest[] = [
optOutFrequencyCap,
gpidPrebidAdUnits,
regionSpecificPrebid,
prebidKeywords,
];
29 changes: 29 additions & 0 deletions src/experiments/tests/prebid-keywords.ts
Original file line number Diff line number Diff line change
@@ -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,
};
17 changes: 17 additions & 0 deletions src/lib/header-bidding/prebid/prebid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -88,6 +89,11 @@ type PbjsConfig = {
timeoutBuffer?: number;
priceGranularity: PrebidPriceGranularity;
userSync: UserSync;
ortb2?: {
site: {
keywords: string;
};
};
consentManagement?: ConsentManagement;
realTimeData?: unknown;
criteo?: {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 758d47c

Please sign in to comment.