diff --git a/scripts/scripts.js b/scripts/scripts.js index 76b3831995..66a7549974 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -168,6 +168,17 @@ async function loadEager(doc) { document.documentElement.lang = 'en'; decorateTemplateAndTheme(); + // Instrument experimentation plugin + if (getMetadata('experiment') + || Object.keys(getAllMetadata('campaign')).length + || Object.keys(getAllMetadata('audience')).length) { + // eslint-disable-next-line import/no-relative-packages + const { loadEager: runEager } = await import('../plugins/experimentation/src/index.js'); + await runEager(document, { audiences: AUDIENCES }, pluginContext); + } + + await initializeDropins(); + window.adobeDataLayer = window.adobeDataLayer || []; let pageType = 'CMS'; @@ -359,16 +370,6 @@ export function getConsent(topic) { } async function loadPage() { - // Instrument experimentation plugin - if (getMetadata('experiment') - || Object.keys(getAllMetadata('campaign')).length - || Object.keys(getAllMetadata('audience')).length) { - // eslint-disable-next-line import/no-relative-packages - const { loadEager: runEager } = await import('../plugins/experimentation/src/index.js'); - await runEager(document, { audiences: AUDIENCES }, pluginContext); - } - - await initializeDropins(); await loadEager(document); await loadLazy(document); loadDelayed();