CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

adobe/aem-eds-personalization

Section-based personalization for AEM Edge Delivery Services (DA) pages: Section Metadata rows let rules (geo, device, visitor, URL/UTM param, page state, custom audiences), a decision engine (v1 API, OF1), an A/B split or Adobe Target (inline or popup) pick the EDS fragment a section shows, with the authored content as default. Consent first, measurement events per decision, a client runtime plus an optional Cloudflare edge worker, a simulator and Playwright checks.

0.83x
Quality

88%

Does it follow best practices?

Impact

83%

0.83x

1 of 3 eval scenarios. Add 2 more for a full score.

SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

preview-and-testing.mdskills/personalize/reference/

Preview and Testing

Contents

  • Preview overrides
  • Local preview
  • Scripts
  • Required checks
  • What verify-preview checks
  • Recipes
  • Skill tests

Preview overrides

The overrides work when config.overrides is preview (the default: *.aem.page, *.hlx.page and localhost) or always. They never work on the live site. They take precedence over bot detection, so headless test browsers can see variants.

ParamEffect
?pzn=home-hero:pro,offer:defaultForce an arm per section, for any source. The outcome is override. default forces the default
?pzn-geo=IN / US-CAFake the geo
?pzn-device=mobileFake the device class
?pzn-visitor=returningFake the visitor
?pzn-state=quiz-persona:cn,step:2Fake the state
?pzn-audience=logged-in,vipForce custom audiences to match
?pzn-consent=1 / 0Fake the consent tool's answer
?pzn-mock=fail | invalid | missing | control | default | reason:<code> | variant:<name>With config.mock: what the mocked engine and Target answer
?pzn-mock-latency=3000With config.mock: delay every mocked answer (the default is 250 ms)
?pzn-debugPrint the decisions table in the console. It only logs; it isn't an override

window.hlx.personalization.preview.consent(true | false) stands in for the consent tool on preview hosts. At the edge, any pzn… param except pzn-debug leaves every section to the browser, when edge-config.overrides allows overrides (the default is never).

Local preview

aem up (aem-cli 16.21+) serves the local content/ tree first and proxies the rest:

  • http://localhost:3000/<page> comes from content/<page>.html;
  • fragments resolve at their real paths, so a variant renders before anything is uploaded;
  • restart aem up when it doesn't pick up a new file.

If verify-preview.mjs reports section not found, check the hooks and how the site renders Section Metadata (authoring-model.md § Rendering prerequisite) before anything else.

Scripts

ScriptPurpose
validate-placeholders.mjs [files|dirs] --repo . [--mode client|edge] [--publish] [--json]Checks the sections against section.schema.json and the cross-row checks; the site config (consent, transport, engine profile, no providers or sendWithoutConsent); engine limits; the page's api request within 256 KiB; no slow engine on a first section in the browser; AEM Experimentation on the section or page; fragments (prefixes, existence, nesting, TODO:, H1); audiences; LCP. --publish fails TODO: copy. Exit 1 on errors, and on INCOMPLETE: a named path that doesn't exist, no config.js, or no personalized section found
install-runtime.mjs <repo> --check-live <origin>Before publishing: main--<repo>--<owner>.aem.live serves this repo's runtime modules and config.js byte for byte, and both scripts.js hooks. Exit 1 on any mismatch, missing file or network error
simulate.mjs <page> [--matrix] [--api-decisions] [--target] [--without-consent rules,api] [--engine of1] [--page-url] [--json]The expected decision per section and case: variant, outcome, source, assigned and result, plus the ?pzn… query that reproduces it. Each section gets a no-consent case, a bot case, one case per rule and per engine answer kind, and a forced case per variant. The slow-engine case uses the site's budgets and api.timeout from config.js
simulate.mjs <page|url> --edge [--consent] [--country --region --cookie --ua --api-decisions --fault --repo]What the edge does per section (applied, selected or left), with its attributes and headers
verify-preview.mjs --page <url> …Playwright checks (below); flags add up. Exit 1 on a failure or a required check not run (INCOMPLETE), 2 on bad usage or when Playwright is missing
mock-decision-api.mjs [--decisions] [--target] [--latency] [--knob] [--ttl] [--cacheable]A local engine (/decide, /feedback) and Target Delivery API that check requests against the schemas (decision-api.md)

Playwright loads from this skill's folder or from ~/.cache/aem-eds-personalization/playwright (PZN_PLAYWRIGHT_DIR overrides the location). It is never loaded from the site: an install there prunes the site's devDependencies and breaks its lint. If verify-preview.mjs exits 2, run the command it prints, once.

Required checks

Each check prints PASS or FAIL. A check that couldn't run is reported as not run, never as passed. Deliver only when every required check passes.

CheckCommandWhen
Authoringvalidate-placeholders.mjs content --repo .Always
Expected outcomessimulate.mjs content/<page>.htmlAlways
Lintnpm run lintAlways
Browserverify-preview.mjs --page <url> --file content/<page>.htmlAlways
Re-evaluation… --refreshapi sections decided in the browser
Failures… --faultsapi, target
Target notifications… --target activities.jsontarget
Splitnpm test (fixed-number boundaries) and … --split-runs 30split
Consent changes… --consent-flowAlways (cmp mode)
Page speed… --perf --baseline <url before>A personalized first section, or layout changes
Pilot baseline… --scenarios assets/contract/pilot-scenarios.jsonThe OF1 pilot page
Edgesimulate.mjs --edge (with and without --consent, and --ua Googlebot), wrangler devEdge mode
Edge latency… --perf --edge --uncached --baseline <unpersonalized url>Edge mode, once deployed

What verify-preview checks

Every case opens the page with its query in a fresh browser context, and checks the following.

  • Sections.
    • Nothing is left hidden (pzn-* status).
    • The expected data-pzn-variant, outcome and source, or one of the allowed arms.
    • The content shown is the variant fragment's (its heading) or the default's.
    • No new console errors, and CLS within budget.
  • Events.
    • Every captured pzn:* event is valid against measurement-event.schema.json and its semantics.
    • One pzn:decided and one pzn:applied per decision, with the expected assigned and result.
    • seen and clicked at most once per decision.
  • No consent.
    • No events, unless the data-layer exception applies.
    • No pzn-* storage, unless the split exception applies.
    • No engine or Target call, unless the api exception applies (Target never).
  • Bots. The default, with no decision call and no split assignment.
  • Target.
    • Inline offers: one display notification once seen, and click on a click.
    • Popups: closed 20 points below the trigger and open past it; modal and labelled; display notified; Escape closes; no reopen for the same decision.
  • --faults.
    • Engine fail, invalid and missing answers, and each reason, end at their outcome: fallback, no-match, low-confidence, control or intentional-default.
    • A Target failure ends at fallback.
    • A 3.5 s answer ends at timeout when the section budget runs out first (the first section, Target), else at fallback after api.timeout, followed by the Rule rows.
    • With config.mock it uses ?pzn-mock; otherwise it routes the engine and Target URLs.
  • --refresh. A browser-decided api section is answered with tracking r1 and then refresh() is called:
    • the same answer: no events;
    • a new tracking: decision #2 with unchanged, and seen again;
    • another variant: the full set of events.
  • --consent-flow. The page loads with pzn-consent=0, then preview.consent(true) and preview.consent(false) are called. It checks the defaults, nothing stored or sent, the #2 decisions with trigger consent, the defaults restored (edge sections too) and storage cleared.
  • --split-runs N. Stickiness across reloads and tabs. Bots and visitors without consent are not assigned. The distribution over N fresh visitors.
  • --scenarios <file>. Each pilot step's engine answer goes through the edge code (served to the browser) or the engine route. The attributes and the ordered events must match.
  • --perf --baseline <url>. A normal visitor with consent and real decisions, for a variant case, a default case, a no-consent case and a slow-engine case. It reports LCP, CLS and the time until the section shows. A CLS regression fails, and so does an LCP regression over 500 ms, or a section with no personalization outcome (runtime or hooks missing). Without --baseline the comparison is not run and the result is INCOMPLETE. --perf alone skips the per-case runs; with --faults, --refresh, --consent-flow, --split-runs or --scenarios those run too.
  • --perf --edge --uncached --baseline <url>. Uncached runs (a unique utm_content each) and cached runs. It reports added time to first byte (all runs, and successful ones only), LCP and CLS at p50 and p75, the success rate, and the timeout, fallback and low-confidence rates. It fails over 300 ms added time to first byte at p75, or under 95 % successful decisions. The visitor has the pzn-consent cookie and ?pzn-consent=1, which stands in for the consent tool on preview hosts: the browser honors an edge decision only when the tool says yes. On a live host the tool must already have consent, or no edge decision counts.

Console errors that also appear on the no-consent or baseline run, and aren't about personalization, are reported as pre-existing and don't fail. --revisit loads the page twice with cookies kept, to check the returning visitor (needs consent).

Recipes

# Rules
node scripts/simulate.mjs content/home.html --page-url http://localhost:3000/home
node scripts/verify-preview.mjs --page http://localhost:3000/home --file content/home.html --consent-flow

# api / target with the in-browser mock (config.mock = { api: <decisions.json>, target: <activities.json> })
node scripts/simulate.mjs content/home.html --api-decisions decisions.json --target activities.json
node scripts/verify-preview.mjs --page http://localhost:3000/home --file content/home.html \
  --api-decisions decisions.json --target activities.json --faults --refresh --ignore-console "status of 5\\d\\d|ERR_"

# api with the mock server instead (api.endpoint = http://127.0.0.1:4100/decide for the test only)
node scripts/mock-decision-api.mjs --decisions decisions.json &
node scripts/verify-preview.mjs --page http://localhost:3000/home --file content/home.html --api-decisions decisions.json --faults

# Split
node scripts/verify-preview.mjs --page http://localhost:3000/home --file content/home.html --split-runs 30

# Page speed against the page before the change (e.g. saved as content/home-before.html)
node scripts/verify-preview.mjs --page http://localhost:3000/home --file content/home.html --perf --baseline http://localhost:3000/home-before

# OF1 pilot
node scripts/verify-preview.mjs --page http://localhost:3000/ --scenarios assets/contract/pilot-scenarios.json

Stop background mocks when you are done. Revert config.mock, api.endpoint, target.endpoint and any test-only consent setting.

Skill tests

npm test in skills/personalize (node --test scripts/test/*.test.mjs) runs every suite:

  • the grammar, rules, outcomes, sources, decision API and context;
  • conformance against the vendored JSON Schemas, examples and OF1 samples;
  • the pilot scenarios through the edge;
  • the edge worker and every CLI.

The browser-runtime suites need Playwright to resolve (from the skill folder or the cache), and are skipped otherwise.

skills

personalize

SKILL.md

README.md

tile.json