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.
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:
"dd/MM/yyyy"11/04/2026"MM/dd/yyyy"04/11/2026"EEEE, MMMM dd"Saturday, April 11"yyyy-MM-dd"2026-04-11y 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:
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:
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 ==):
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 InformationenRezepte 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:
Ausgabe (Beispiel):
- Running shoes: 89€
- Water bottle: 15€
- Gym bag: 45€
{{#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}}:
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:
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:
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 (\"):
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:
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:
Oder inline mit einem Muster im ternären Stil mit isEmpty:
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 %}
{%= ... %}) 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():
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 %}
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 withtopN, or render content only for array items that match a condition. - Clean a string with
replaceAlland 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 byprice, 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}}withas |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
yandY: In date format patterns, lowercaseyis the calendar year and uppercaseYis the week-based year.
Guardrails:
this.statusworks 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
topNreturn the first N items of an array? No.topNsorts 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.statusis 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"gives11/04/2026,"MM/dd/yyyy"gives04/11/2026,"EEEE, MMMM dd"givesSaturday, April 11, and"yyyy-MM-dd"gives2026-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") %}usesaddDayswith a negative offset. To also set a fixed time of day, such as 9 AM, combine it withsetHours. - Time only:
extractHoursandextractMinutesshow only the time portion, with a leading-zero guard for minutes ({%#if m < 10%}0{%/if%}), for exampleYour 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. BecausetopNis 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 exampleHi John,andWELCOME-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 asHi there,, or inline withisEmpty: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 thanY(week-based year) in date format patterns to avoid unexpected results at year boundaries. - Use
{% let %}to store the result ofreplaceAlland reference it multiple times without repeating the function call.
Related pages:
- For a complete reference of available functions: Helper functions
- For a complete reference of available functions: Date/time functions
- For a complete reference of available functions: String functions
- For a complete reference of available functions: Array functions
- Before copying examples, to avoid the most common syntax errors: Personalization best practices
- For routing profiles in a journey based on the day of the week: Condition activity
- For array filtering in journey conditions: collection management functions
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