Skip to content
Open
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
13 changes: 13 additions & 0 deletions ab-testing/config/abTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ const ABTests: ABTest[] = [
groups: ["holdback"],
shouldForceMetricsCollection: true,
},
{
name: "commercial-fronts-ad-increase-ad-limit",
description:
"A test to understand the impact of changing page-level ad limit on fronts",
owners: ["commercial.dev@guardian.co.uk"],
expirationDate: "2026-08-11",
type: "client",
status: "ON",
audienceSize: 10 / 100,
audienceSpace: "A",
groups: ["control", "variant"],
shouldForceMetricsCollection: true,
},
{
name: "newsletters-in-article-signup-preview",
description:
Expand Down
8 changes: 7 additions & 1 deletion dotcom-rendering/src/layouts/FrontLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { SubNav } from '../components/SubNav.island';
import { TrendingTopics } from '../components/TrendingTopics';
import { ArticleDisplay } from '../lib/articleFormat';
import { canRenderAds } from '../lib/canRenderAds';
import { getMaxFrontsBannerAds } from '../lib/commercial-constants';
import { getContributionsServiceUrl } from '../lib/contributions';
import { editionList } from '../lib/edition';
import {
Expand All @@ -40,6 +41,7 @@ import {
} from '../lib/getFrontsAdPositions';
import { hideAge } from '../lib/hideAge';
import { ophanComponentId } from '../lib/ophan-helpers';
import { useAB } from '../lib/useAB';
import { worldCup2026PageIds } from '../lib/worldCup2026';
import type { NavType } from '../model/extract-nav';
import { palette as schemePalette } from '../palette';
Expand Down Expand Up @@ -117,6 +119,10 @@ export const FrontLayout = ({ front, NAV }: Props) => {
editionId,
} = front;

const abTests = useAB();

const maxAds = getMaxFrontsBannerAds(abTests);

const serverTime = front.serverTime;

const renderAds = canRenderAds(front);
Expand All @@ -136,7 +142,7 @@ export const FrontLayout = ({ front, NAV }: Props) => {
: [];

const desktopAdPositions = renderAds
? getDesktopAdPositions(filteredCollections, pageId)
? getDesktopAdPositions(filteredCollections, pageId, maxAds)
: [];

const showMostPopular =
Expand Down
14 changes: 14 additions & 0 deletions dotcom-rendering/src/lib/commercial-constants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import type { ABTestAPI } from '../experiments/lib/ab-tests';

/**
* The maximum number of fronts-banner ads that can be inserted on any front.
* fronts-banner ads are inserted from the desktop breakpoint.
*/
export const MAX_FRONTS_BANNER_ADS = 8;

export const getMaxFrontsBannerAds = (
abTests: ABTestAPI | undefined,
): number => {
const isInVariantAdLimitGroup =
abTests?.isUserInTestGroup(
'commercial-fronts-ad-increase-ad-limit',
'variant',
) ?? false;

return isInVariantAdLimitGroup ? 16 : MAX_FRONTS_BANNER_ADS;
};

/**
* The maximum number of ads that can be inserted on any mobile front.
* Mobile ads on fronts are inserted up until the tablet breakpoint.
Expand Down
3 changes: 1 addition & 2 deletions dotcom-rendering/src/lib/getFrontsAdPositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,8 @@ const canInsertDesktopAd = (
const getDesktopAdPositions = (
collections: AdCandidate[],
pageId: string,
maxAdsAllowed = MAX_FRONTS_BANNER_ADS,
): number[] => {
const maxAdsAllowed = MAX_FRONTS_BANNER_ADS;

const adPositionsFromReducer = collections.reduce<{
heightSinceAd: number;
adPositions: number[];
Expand Down
Loading