Personalisierungsrezepte personalization-recipes

Auf dieser Seite: Nutzen Sie sofort umsetzbare Personalisierungsrezepte für Datumsangaben, Arrays, Zeichenfolgen, bedingte Logik und PQL-Randfälle, die Sie direkt in Ihren Adobe Journey Optimizer-Inhalt kopieren können.

Diese Seite stellt einsatzbereite Personalisierungsmuster für die häufigsten Anwendungsfälle in Journey Optimizer bereit. Alle Beispiele verwenden die Syntax des Personalisierungseditors und können direkt in E-Mail-, Mobile- oder Push-Inhalte kopiert werden.

Eine vollständige Übersicht der verfügbaren Funktionen finden Sie in den Hilfsfunktionen, Datums-/Uhrzeitfunktionen, Zeichenfolgenfunktionen und Array-Funktionen.

TIP
Bevor Sie Beispiele kopieren, lesen Sie die Best Practices für die Personalisierung, um die häufigsten Syntaxfehler zu vermeiden.

Rezepte für Datum und Uhrzeit date-time-recipes

Rezept 1: Anzeige des aktuellen Datums in einem lesbaren Format recipe-current-date

Verwenden Sie formatDate mit getCurrentZonedDateTime(), um das heutige Datum in einem beliebigen Format wiederzugeben:

{%= formatDate(getCurrentZonedDateTime(), "MMMM dd, yyyy") %}

Ausgabe (Beispiel): April 11, 2026

Gängige Formatmuster:

Muster
Ausgabebeispiel
"dd/MM/yyyy"
11/04/2026
"MM/dd/yyyy"
04/11/2026
"EEEE, MMMM dd"
Saturday, April 11
"yyyy-MM-dd"
2026-04-11
NOTE
Verwenden Sie y in Kleinbuchstaben (Kalenderjahr) anstelle von Y (Jahr auf Wochenbasis), um unerwartete Ergebnisse an Jahresgrenzen zu vermeiden. Eine vollständige Referenz finden Sie unter Musterzeichen.

Rezept 2: Countdown bis zu einem Ablauf- oder Ereignisdatum recipe-countdown

Verwenden Sie dateDiff, um die Anzahl der verbleibenden Tage bis zu einem Profildatumsattribut zu berechnen und es dann dynamisch zu rendern:

{% let daysLeft = dateDiff(getCurrentZonedDateTime(), stringToDate(profile.loyalty.expiryDate)) %}
{%#if daysLeft > 0%}
Your reward points expire in {{daysLeft}} day{%#if daysLeft > 1%}s{%/if%}. Use them before they're gone!
{%else%}
Your reward points have expired.
{%/if%}

Ausgabe (Beispiel): Your reward points expire in 7 days. Use them before they're gone!

Rezept 3: x Tage vor einem dynamischen Enddatum recipe-days-before

Um ein Datum zu berechnen, das x Tage vor einem Profilattribut liegt (z. B. um Inhalt oder Betreffzeilen aufzunehmen), verwenden Sie addDays mit einem negativen Versatz:

{%= formatDate(addDays(stringToDate(profile.subscription.endDate), -7), "MMMM dd, yyyy") %}

Ausgabe (Beispiel): April 04, 2026 (7 Tage vor dem 11. April)

Um auch eine feste Uhrzeit festzulegen (z. B. 9 Uhr morgens), kombinieren Sie dies mit setHours:

{%= formatDate(setHours(addDays(stringToDate(profile.subscription.endDate), -7), 9), "dd/MM/yyyy HH:mm") %}

Rezept 4: Anzeige der aktuellen Zeit nur als HH:MM recipe-time-only

Verwenden Sie extractHours und extractMinutes, um nur den Zeitteil mit führenden Nullen für Minuten anzuzeigen:

{% let h = extractHours(getCurrentZonedDateTime()) %}
{% let m = extractMinutes(getCurrentZonedDateTime()) %}
Your appointment is at {{h}}:{%#if m < 10%}0{%/if%}{{m}}.

Ausgabe (Beispiel): Your appointment is at 14:05.

Rezept 5: Unterscheidung von Wochenenden und Werktagen recipe-weekend

Verwenden Sie dayOfWeek, um Inhalte auf Basis des Tags anzupassen. Die Funktion gibt 1 (Montag) bis 7 (Sonntag) zurück. Verwenden Sie den einzelnen Operator = (PQL-Syntax, nicht ==):

{%#if dayOfWeek(getCurrentZonedDateTime()) = 6 or dayOfWeek(getCurrentZonedDateTime()) = 7%}
We're closed on weekends — our team will follow up on the next business day.
{%else%}
Our team will get back to you within 24 hours.
{%/if%}
NOTE
dayOfWeek() dient der Anpassung des Inhalts auf Basis des Tags. Wenn Sie Profile in einer Journey abhängig vom Wochentag unterschiedlich weiterleiten möchten, verwenden Sie die integrierte Option Zeitbedingung > Wochentag in der Aktivität „Bedingung“ der Journey. Weitere Informationen

Rezepte für Arrays und Schleifen array-recipes

Rezept 6: Auflistung aller Elemente aus einem Profil-Array recipe-list-items

Verwenden Sie {{#each}}, um eine Iteration über ein Profil-Array vorzunehmen und jedes Element zu rendern. Dies ist nur im Personalisierungseditor (E-Mail, Mobile, Push) verfügbar:

{{#each profile.purchases.recentItems}}
  - {{this.name}}: {{this.price}}&euro;
{{/each}}

Ausgabe (Beispiel):

- Running shoes: 89&euro;
- Water bottle: 15&euro;
- Gym bag: 45&euro;
NOTE
In der Aktivität „Journey-Bedingung“ wird {{#each}} nicht unterstützt. Verwenden Sie zum Filtern von Arrays in Bedingungen Funktionen zur Verwaltung von Sammlungen.

Rezept 7: Anzeige der Top-N-Elemente aus einem Array nach Preis recipe-first-n

Verwenden Sie topN, um die Top-N-Elemente nach einem numerischen Feld zu sortieren und abzurufen. Da topN eine PQL-Funktion ist, weisen Sie sie zuerst mit {% let %} einer Variablen zu und durchlaufen Sie dann eine Schleife mit {{#each}}:

{% let topOrders = topN(profile.orders, price, 3) %}
{{#each topOrders}}
  {{this.name}} — {{this.price}}&euro;
{{/each}}
NOTE
topN(profile.orders, price, 3) sortiert Bestellungen nach price in absteigender Reihenfolge und gibt die Top 3 zurück. Es werden also nicht einfach die ersten drei Elemente in der ursprünglichen Array-Reihenfolge zurückgegeben.

Sie können auch head verwenden, um nur das relevanteste Element abzurufen:

{%= head(profile.purchases.recentItems).name %}

Rezept 8: Bedingtes Rendern des Inhalts nach Array-Element recipe-conditional-loop

Verwenden Sie {%#if%} in {{#each}}, um die Ausgabe nur für übereinstimmende Elemente zu rendern. Definieren Sie einen Schleifen-Alias mit as |order|, damit der PQL-Auswerter den Attributverweis in der Bedingung auflösen kann:

{{#each profile.orders as |order|}}
  {%#if order.status = "pending"%}
  Order {{order.id}} is pending — we'll notify you when it ships.
  {%/if%}
{{/each}}
NOTE
this.status funktioniert in Handlebars-Ausdrücken, wird aber vom PQL-Auswerter in {%#if%} nicht aufgelöst. Durch die Verwendung eines benannten Schleifen-Alias (z. B. order) wird das Attribut sowohl für den Handlebars- als auch für den PQL-Kontext verfügbar.

Zeichenfolgen- und Formatierungsrezepte string-recipes

Rezept 9 – Bereinigen und Wiederverwenden einer Zeichenfolge mit replaceAll recipe-replaceall-reuse

replaceAll gibt einen neuen Wert zurück – das Original wird nicht geändert. Verwenden Sie {% let %}, um das Ergebnis zu speichern und mehrmals darauf zu verweisen, ohne den Funktionsaufruf zu wiederholen:

{% let cleanName = replaceAll(profile.person.name.firstName, "[^a-zA-Z]", "") %}
Hi {{cleanName}},
Your exclusive code is: WELCOME-{%= upperCase(cleanName) %}

Ausgabe (Beispiel):

Hi John,
Your exclusive code is: WELCOME-JOHN

Rezept 10 - Einschließen eines Werts in doppelte Anführungszeichen in der JSON-Ausgabe recipe-json-quotes

Um ein Literal in einer Zeichenfolge in doppelte Anführungszeichen einzuschließen (z. B. um JSON für eine benutzerdefinierte Payload zu generieren), maskieren Sie die Anführungszeichen mit einem umgekehrten Schrägstrich (\"):

{ "greeting": "Hello \"{{profile.person.name.firstName}}\"" }

Ausgabe: { "greeting": "Hello \"John\"" }

Rezept 11 – Formatieren einer Datumskomponente in Großbuchstaben recipe-uppercase-date

Kombinieren Sie formatDate mit upperCase, um Monats- oder Tagesnamen in Großbuchstaben auszugeben:

{%= upperCase(formatDate(getCurrentZonedDateTime(), "MMMM")) %}

Ausgabe (Beispiel): APRIL

Für eine vollständige Datumszeichenfolge in Großbuchstaben:

{%= upperCase(formatDate(profile.person.birthDateTime, "EEEE MMMM dd yyyy")) %}

Ausgabe (Beispiel): WEDNESDAY JANUARY 01 2020

Rezepte für bedingte Logik conditional-recipes

Rezept 12 – IF/ELSEIF/ELSE in personalisierten Inhalten recipe-if-elseif

Verwenden Sie {%#if%}, {%else if%} und {%else%} für eine bedingte Logik mit mehreren Verzweigungen. Dieses Muster funktioniert in E-Mail-Inhalten und -Fragmenten:

{%#if profile.loyalty.tier = "gold"%}
As a Gold member, enjoy free shipping on all orders.
{%else if profile.loyalty.tier = "silver"%}
As a Silver member, enjoy free shipping on orders over &euro;50.
{%else%}
Join our loyalty program to unlock exclusive benefits.
{%/if%}

Rezept 13 – Null-sichere Attributanzeige recipe-null-safe

Verwenden Sie ein bedingtes Fallback, um zu vermeiden, dass leere Werte dargestellt werden, wenn ein Profilattribut null ist oder fehlt:

{%#if profile.person.name.firstName%}
Hi {{profile.person.name.firstName}},
{%else%}
Hi there,
{%/if%}

Oder inline mit einem Muster im ternären Stil mit isEmpty:

Hi {%#if isEmpty(profile.person.name.firstName)%}valued customer{%else%}{{profile.person.name.firstName}}{%/if%},

Rezepte für PQL-Randfälle pql-edge-cases

Rezept 14 – Verweisen auf Attributschlüssel mit Bindestrichen recipe-hyphenated-key

Wenn der XDM-Schemafeldname Bindestriche enthält (z. B. order-total, event-type), schließen Sie ihn in einen PQL-Ausdruck mit Backticks ein, um zu verhindern, dass der Bindestrich als Subtraktionsoperator interpretiert wird:

{%= profile.events.`order-total` > 100 %}
NOTE
Backticks werden nur innerhalb von PQL-Ausdrücken ({%= ... %}) unterstützt. Sie werden in der reinen Handlebars-Interpolation ({{...}}) nicht akzeptiert. Wenn Sie einen Feldwert mit Bindestrich direkt darstellen müssen, werten Sie ihn über einen PQL-Ausdruck aus oder speichern Sie ihn zuerst mit {% let %} in einer Variablen.

Rezept 15 – Verweisen auf eine numerische Ereignis-ID in einem Kontextattribut recipe-numeric-event-id

Wenn Sie ein Journey-Kontextereignis verwenden, dessen ID eine numerische Zeichenfolge ist (z. B. 1697323153), schließen Sie die ID in Backticks ein und verwenden Sie {% let %} mit toDateTime() und formatDate():

{% let appointmentDate = formatDate(toDateTime(context.journey.events.`1697323153`.timestamp), "dd/MM/yyyy HH:mm") %}
Your appointment: {{appointmentDate}}

Ausgabe (Beispiel): Your appointment: 18/03/2026 14:30

Rezept 16 - Typ-Erzwingung: Vergleichen eines Zeichenfolgenfelds mit einer Zahl recipe-type-coercion

PQL ist strikt typisiert. Wenn ein Profilfeld als Zeichenfolge gespeichert wird, Sie es jedoch numerisch vergleichen müssen, konvertieren Sie es zuerst mit stringToNumber():

{%= stringToNumber(profile.loyalty.pointsBalance) > 500 %}

Für boolesche Felder, die als Zeichenfolgen gespeichert werden:

{%= toBool(profile.consents.email.val) = true %}
AI Knowledge Reference

This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.

For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.

  • TL;DR: This page gives ready-to-use personalization recipes for dates, arrays, strings, conditional logic, and PQL edge cases, written in personalization editor syntax that can be copied directly into email, mobile, or push content in Adobe Journey Optimizer.

Intents:

  • Display the current date or time in a readable format, compute a countdown in days to a profile date attribute, or compute a date X days before a profile date attribute.
  • List the items of a profile array with {{#each}}, show the top N items of an array by price with topN, or render content only for array items that match a condition.
  • Clean a string with replaceAll and reuse the result, include a literal double quote in JSON output, or render a month or day name in uppercase.
  • Build multi-branch conditional content with {%#if%}, {%else if%}, and {%else%}, and display a fallback when a profile attribute may be null or missing.
  • Reference a hyphenated XDM schema field name, a journey context event whose ID is a numeric string, or a string field that must be compared as a number or a boolean.

Glossary:

  • topN: A PQL function that sorts an array by a numeric field in descending order and returns the top N items. topN(profile.orders, price, 3) returns the top 3 orders by price, not the first 3 items in the original array order.
  • dayOfWeek: A function that returns 1 (Monday) through 7 (Sunday). It is for adapting content based on the day.
  • replaceAll: A function that returns a new value and does not modify the original value.
  • Loop alias: A name defined in {{#each}} with as |order|. A named loop alias makes the attribute available to both the Handlebars and PQL contexts, so the PQL evaluator can resolve the attribute reference in a {%#if%} condition inside the loop.
  • Pattern characters y and Y: In date format patterns, lowercase y is the calendar year and uppercase Y is the week-based year.

Guardrails:

  • this.status works in Handlebars expressions but is not resolved by the PQL evaluator inside {%#if%}.
  • Backticks are only supported inside PQL expressions ({%= ... %}). They are not accepted in plain Handlebars interpolation ({{...}}).
  • PQL is strongly typed: when a profile field is stored as a string and you need to compare it numerically, convert it first with stringToNumber().
  • When comparing the result of dayOfWeek, use the single = operator (PQL syntax), not ==.

Applicability:

  • {{#each}}: available in the personalization editor (email, mobile, push) only. Not supported in the journey condition activity.
  • The IF/ELSEIF/ELSE pattern ({%#if%}, {%else if%}, {%else%}): works in email content and fragments.

Terminology:

  • Canonical name: Experience Data Model — Acronym: XDM — variants: XDM schema
  • Do not confuse: dayOfWeek() (adapts content based on the day) ≠ the Time condition, Day of the week option of the journey Condition activity (routes profiles differently in a journey based on the day of the week).

FAQ:

  • Does topN return the first N items of an array? No. topN sorts the array by the numeric field in descending order and returns the top N items.
  • Why define a loop alias such as as |order| in {{#each}}? So the PQL evaluator can resolve the attribute reference in a {%#if%} condition inside the loop. this.status is not resolved by the PQL evaluator inside {%#if%}.
  • Can I use {{#each}} in a journey condition activity? No. For array filtering in conditions, use collection management functions.
  • How do I route profiles differently in a journey based on the day of the week? Use the built-in Time condition, Day of the week option in the journey Condition activity, not dayOfWeek().
  • How do I reference an XDM schema field name that contains hyphens? Wrap it in backticks inside a PQL expression, so the hyphen is not interpreted as a subtraction operator. To render the value directly, evaluate it through a PQL expression or store it in a variable with {% let %} first.
  • How do I compare a string field to a number? Convert it first with stringToNumber(), for example {%= stringToNumber(profile.loyalty.pointsBalance) > 500 %}.

Examples:

  • Current date: {%= formatDate(getCurrentZonedDateTime(), "MMMM dd, yyyy") %} renders, for example, April 11, 2026. Other format patterns: "dd/MM/yyyy" gives 11/04/2026, "MM/dd/yyyy" gives 04/11/2026, "EEEE, MMMM dd" gives Saturday, April 11, and "yyyy-MM-dd" gives 2026-04-11.
  • Countdown: {% let daysLeft = dateDiff(getCurrentZonedDateTime(), stringToDate(profile.loyalty.expiryDate)) %} computes the number of days remaining until a profile date attribute, then {%#if daysLeft > 0%} renders the countdown or an expired message.
  • X days before a date: {%= formatDate(addDays(stringToDate(profile.subscription.endDate), -7), "MMMM dd, yyyy") %} uses addDays with a negative offset. To also set a fixed time of day, such as 9 AM, combine it with setHours.
  • Time only: extractHours and extractMinutes show only the time portion, with a leading-zero guard for minutes ({%#if m < 10%}0{%/if%}), for example Your appointment is at 14:05.
  • Weekend detection: {%#if dayOfWeek(getCurrentZonedDateTime()) = 6 or dayOfWeek(getCurrentZonedDateTime()) = 7%} renders weekend content.
  • Top N items: {% let topOrders = topN(profile.orders, price, 3) %}, then a {{#each topOrders}} loop. Because topN is a PQL function, it is assigned to a variable first with {% let %}.
  • Conditional per array item: {{#each profile.orders as |order|}} with {%#if order.status = "pending"%} inside the loop.
  • Reused string: {% let cleanName = replaceAll(profile.person.name.firstName, "[^a-zA-Z]", "") %}, then {{cleanName}} and {%= upperCase(cleanName) %}, for example Hi John, and WELCOME-JOHN.
  • Double quote in JSON output (for example for a custom payload): escape it with a backslash (\"), as in { "greeting": "Hello \"{{profile.person.name.firstName}}\"" }.
  • Uppercase date: {%= upperCase(formatDate(getCurrentZonedDateTime(), "MMMM")) %} renders, for example, APRIL.
  • Null-safe display: {%#if profile.person.name.firstName%} with an {%else%} fallback such as Hi there,, or inline with isEmpty: Hi {%#if isEmpty(profile.person.name.firstName)%}valued customer{%else%}{{profile.person.name.firstName}}{%/if%},.
  • Boolean stored as a string: {%= toBool(profile.consents.email.val) = true %}.

Best practices:

  • Use lowercase y (calendar year) rather than Y (week-based year) in date format patterns to avoid unexpected results at year boundaries.
  • Use {% let %} to store the result of replaceAll and reference it multiple times without repeating the function call.

Related pages:

Personas:

  • developer: Can reference a hyphenated XDM schema field name by wrapping it in backticks inside a PQL expression. Can reference a journey context event whose ID is a numeric string by wrapping the ID in backticks. Can convert a string field with stringToNumber() before comparing it numerically. The page states that backticks are only supported inside PQL expressions ({%= ... %}). Where: “PQL edge case recipes”.

Onboarding:

  • Level: Experienced
  • First minimal step: Review the Personalization best practices before copying examples, to avoid the most common syntax errors.
  • Previous: Before copying examples, to avoid the most common syntax errors: Personalization best practices
recommendation-more-help
journey-optimizer-help