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

feat: 0% AB test to limit inline merch slots #884

Merged
merged 5 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AdSize, SizeMapping } from '@guardian/commercial-core';
import { adSizes, createAdSlot } from '@guardian/commercial-core';
import { shouldAddInlineMerchAd } from 'common/modules/commercial/inline-merch';
import { isInEagerPrebidVariant } from 'common/modules/experiments/eager-prebid-check';
import {
getCurrentBreakpoint,
Expand Down Expand Up @@ -417,7 +418,7 @@ const doInit = async (): Promise<boolean> => {

insertedDynamicAds = [];

const im = window.guardian.config.page.hasInlineMerchandise
const im = shouldAddInlineMerchAd()
? attemptToAddInlineMerchAd()
: Promise.resolve(false);
const inlineMerchAdded = await im;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { isInVariantSynchronous } from '../experiments/ab';
import { shouldAddInlineMerchAd } from './inline-merch';

jest.mock('common/modules/experiments/ab', () => ({
isInVariantSynchronous: jest.fn(),
}));

afterEach(() => {
jest.clearAllMocks();
});

describe('shouldAddInlineMerchAd', () => {
it('returns false when in the variant and page is not eligible', () => {
(isInVariantSynchronous as jest.Mock).mockReturnValue(true);
window.guardian.config.page.hasInlineMerchandise = false;
expect(shouldAddInlineMerchAd()).toBe(false);
});

it('returns false when not in the variant and page is not eligible', () => {
(isInVariantSynchronous as jest.Mock).mockReturnValue(false);
window.guardian.config.page.hasInlineMerchandise = false;
expect(shouldAddInlineMerchAd()).toBe(false);
});

it('returns true when not in the variant and page is eligible', () => {
(isInVariantSynchronous as jest.Mock).mockReturnValue(false);
window.guardian.config.page.hasInlineMerchandise = true;
expect(shouldAddInlineMerchAd()).toBe(true);
});

it('returns false when in the variant and the page is eligible', () => {
(isInVariantSynchronous as jest.Mock).mockReturnValue(true);
window.guardian.config.page.hasInlineMerchandise = true;
expect(shouldAddInlineMerchAd()).toBe(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { isInVariantSynchronous } from '../experiments/ab';
import { limitInlineMerch } from '../experiments/tests/limit-inline-merch';

export const shouldAddInlineMerchAd = () =>
window.guardian.config.page.hasInlineMerchandise &&
!isInVariantSynchronous(limitInlineMerch, 'variant');
2 changes: 2 additions & 0 deletions bundle/src/projects/common/modules/experiments/ab-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { deeplyReadArticleFooterTest } from './tests/deeply-read-article-footer'
import { eagerPrebid } from './tests/eager-prebid';
import { elementsManager } from './tests/elements-manager';
import { integrateIma } from './tests/integrate-ima';
import { limitInlineMerch } from './tests/limit-inline-merch';
import { remoteRRHeaderLinksTest } from './tests/remote-header-test';
import { signInGateCopyTestJan2023 } from './tests/sign-in-gate-copy-test-variant';
import { signInGateMainControl } from './tests/sign-in-gate-main-control';
Expand All @@ -23,4 +24,5 @@ export const concurrentTests: readonly ABTest[] = [
billboardsInMerch,
elementsManager,
eagerPrebid,
limitInlineMerch,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { ABTest } from '@guardian/ab-core';

export const limitInlineMerch: ABTest = {
id: 'LimitInlineMerch',
start: '2023-06-23',
expiry: '2023-09-01',
author: '@chrislomaxjones',
description:
'Test the impact of limiting the eligibility of inline merchandising ad slots',
audience: 0 / 100,
audienceOffset: 0 / 100,
audienceCriteria:
'Article pages eligible for rendering an inline merchandising ad slot',
successMeasure:
'Limiting the presence of inline merchandising ad slots increases ad-ratio on eligible article pages',
canRun: () => !!window.guardian.config.page.hasInlineMerchandise,
variants: [
{
id: 'control',
test: (): void => {
/* no-op */
},
},
{
id: 'variant',
test: (): void => {
/* no-op */
},
},
],
};
Loading