From 5e7576382ec2951914867c3713448d7f7a27708e Mon Sep 17 00:00:00 2001 From: Xinyi Feng Date: Tue, 10 Mar 2026 14:01:50 -0700 Subject: [PATCH 1/2] feat: detect variant pages via experiment-control-path metadata Set window.hlx.variantPage with controlPath and experimentId when a page has both experiment and experiment-control-path metadata, enabling the MFE to block experiment creation on variant pages. Co-Authored-By: Claude Opus 4.6 --- src/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index.js b/src/index.js index eb528c0..b77723a 100644 --- a/src/index.js +++ b/src/index.js @@ -1103,6 +1103,17 @@ export async function loadEager(document, options = {}) { const ns = window.aem || window.hlx || {}; ns.experimentation = { version: VERSION }; + + // Detect variant pages (has experiment ID + control path but no variant definitions) + const controlPath = getMetadata(`${pluginOptions.experimentsMetaTagPrefix}-control-path`); + const experimentId = getMetadata(pluginOptions.experimentsMetaTagPrefix); + if (controlPath && experimentId) { + ns.variantPage = { + controlPath, + experimentId, + }; + } + ns.audiences = await serveAudience(document, pluginOptions); ns.experiments = await runExperiment(document, pluginOptions); ns.campaigns = await runCampaign(document, pluginOptions); From 11e9b69831c527251cf2d54d205b0ff43892e303 Mon Sep 17 00:00:00 2001 From: Xinyi Feng Date: Tue, 10 Mar 2026 14:06:43 -0700 Subject: [PATCH 2/2] chore: update comment wording Co-Authored-By: Claude Opus 4.6 --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b77723a..daf1f49 100644 --- a/src/index.js +++ b/src/index.js @@ -1104,7 +1104,7 @@ export async function loadEager(document, options = {}) { const ns = window.aem || window.hlx || {}; ns.experimentation = { version: VERSION }; - // Detect variant pages (has experiment ID + control path but no variant definitions) + // Detect variant pages (has experiment ID + control path only) const controlPath = getMetadata(`${pluginOptions.experimentsMetaTagPrefix}-control-path`); const experimentId = getMetadata(pluginOptions.experimentsMetaTagPrefix); if (controlPath && experimentId) {