Skip to content
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
7 changes: 4 additions & 3 deletions ab-testing/config/abTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,16 @@ const ABTests: ABTest[] = [
shouldForceMetricsCollection: false,
},
{
name: "growth-admiral-adblock-recovery",
description: "Test Admiral ad blocker detection and recovery modal",
name: "growth-admiral-adblock-detect",
description:
"Control group for Admiral ad blocker - runs the detection script but does not show the modal",
owners: ["growth.dev@guardian.co.uk"],
expirationDate: "2027-01-21",
type: "client",
status: "ON",
audienceSize: 10 / 100,
audienceSpace: "A",
groups: ["control"],
groups: ["variant-detect"],
shouldForceMetricsCollection: false,
},
{
Expand Down
14 changes: 7 additions & 7 deletions dotcom-rendering/src/components/AdmiralScript.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,23 +210,24 @@ const testName = 'growth-admiral-adblock-recovery';
export const AdmiralScript = () => {
const { renderingTarget } = useConfig();
const abTests = useBetaAB();
const isInControlGroup =
abTests?.isUserInTestGroup(testName, 'control') ?? false;
const variantName = isInControlGroup ? 'control' : undefined;
const isInVariantDetectGroup =
abTests?.isUserInTestGroup(testName, 'variant-detect') ?? false;
const variantName = isInVariantDetectGroup
? 'variant-detect'
: 'variant-recover'; //We need to default to 'variant-recover' for users who are not in the AB test in order to show Admiral Modal to all users in the US who are not blocked by the CMP and meet the other criteria.

useEffect(() => {
/**
* The Admiral bootstrap script should only run under the following conditions:
*
* - Should not run if the CMP is due to show
* - Should only run in the US
* - Should only run if in the AB test (control group)
* - Should not run if the gu_hide_support_messaging cookie is set
* - Should not run for content marked as: shouldHideAdverts, shouldHideReaderRevenue, isSensitive
* - Should not run for paid-content sponsorship type (includes Hosted Content)
* - Should not run for certain sections
*
* Control group loads the script but the modal will not be shown.
* Variant-detect group loads the script but the modal will not be shown.
*/
const page = window.guardian.config.page;
if (!window.guardian.config.switches.consentManagement) return;
Expand All @@ -242,7 +243,6 @@ export const AdmiralScript = () => {
const shouldRun =
!willShowPrivacyMessage &&
isInUsa() &&
isInControlGroup &&
!getCookie({
name: 'gu_hide_support_messaging',
shouldMemoize: true,
Expand Down Expand Up @@ -319,7 +319,7 @@ export const AdmiralScript = () => {
isCancelled = true;
admiralScript?.parentNode?.removeChild(admiralScript);
};
}, [isInControlGroup, variantName, renderingTarget]);
}, [variantName, renderingTarget]);

return null;
};
Loading