Skip to content

feat(nx2): Omega Adobe Launch + GTM injected at end of body#444

Open
anfibiacreativa wants to merge 5 commits into
ewfrom
ew-omega-launch
Open

feat(nx2): Omega Adobe Launch + GTM injected at end of body#444
anfibiacreativa wants to merge 5 commits into
ewfrom
ew-omega-launch

Conversation

@anfibiacreativa
Copy link
Copy Markdown
Member

@anfibiacreativa anfibiacreativa commented May 14, 2026

Summary

  • After the nx2 shell loads (scripts.js), append the Adobe Launch stage bootstrap and (when configured) Google Tag Manager to the end of document.body, not to <head>, so Omega can test whether tracking still loads correctly with a deferred / bottom-of-page injection.
  • Intended for Omega team validation on EW / branch previews (*.da.live, localhost) authoring pages.

Why

  • Omega requires Launch for analytics into Omega.
  • We need to validate the GTM script at the bottom of the page (vs head) and to confirm things still load.

What Changed

  • New nx2/utils/omega-tracking.js: initOmegaTracking() gates on env (from nx.js): runs on non-prod hosts; on prod only if <meta name="omega-tracking" content="on"> is present.
  • Placement: Launch and GTM script nodes use document.body.append(...) after loadPage() — nothing from this module is inserted into document.head.
  • GTM when: <meta name="gtm-id" content="GTM-…"> must be set (strict GTM-[A-Z0-9]+); there is no hardcoded container id in repo. Same file builds gtm.js URL and appends the hidden noscript iframe to the body end.
  • Launch URL is the fixed stage bootstrap: exc-unifiedcontent.experience-stage.adobe.net/.../launch-3e9e0f669557-development.min.js.
  • nx2/scripts/scripts.js calls initOmegaTracking() immediately after await loadPage().

Test Plan

  • Placement: In DevTools Elements, confirm new script tags for Launch (and GTM if meta set) are last children of body, not under head.
  • Branch preview is branch ew or ew-omega-*
  • Set gtm-id meta to a test container; confirm gtm.js and dataLayer.

https://ew-omega-launch--da-nx--adobe.aem.page/

Append the stage Launch bootstrap URL after page load for non-prod hosts
and branch previews, with an opt-in for production via meta omega-tracking.

Google Tag Manager loads when meta gtm-id contains a valid GTM- container id.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aem-code-sync
Copy link
Copy Markdown

aem-code-sync Bot commented May 14, 2026

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

Allow Launch/GTM injection on prod-like hosts when the URL has
nx=ew or nx=ew-omega-* (any branch matching that prefix), or when
meta omega-tracking is set to on.

Also adds PR-throwaways/ to .gitignore.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aem-code-sync aem-code-sync Bot temporarily deployed to ew-omega-launch May 14, 2026 19:53 Inactive
Co-authored-by: Cursor <cursoragent@cursor.com>
@aem-code-sync aem-code-sync Bot temporarily deployed to ew-omega-launch May 14, 2026 19:58 Inactive
scripts.js only runs for AEM content pages via head.html; the canvas
route on da.live never loads it. Move the call into loadArea (nx.js)
which is the universal entry point for all page types.

Co-authored-by: Cursor <cursoragent@cursor.com>
@aem-code-sync aem-code-sync Bot temporarily deployed to ew-omega-launch May 14, 2026 20:10 Inactive
Replaces the blanket `env !== 'prod'` check that fired on every
aem.page preview with an explicit host+path gate: only da.live
(or localhost) on /canvas and /browse, gated by nx=ew or
nx=ew-omega-* query param (or omega-tracking meta override).

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant