このページ:日付、配列、文字列、条件付きロジック、PQL エッジケースに対して、すぐに使用できるパーソナライゼーションレシピについて説明します。これにより、Adobe Journey Optimizer コンテンツに直接コピーできます。
このページでは、Adobe Journey Optimizer で最も一般的なユースケースに対して、すぐに使用できるパーソナライゼーションパターンについて説明します。 あらゆる例でパーソナライゼーションエディターの構文を使用しており、電子メール、モバイル、プッシュコンテンツに直接コピーできます。
使用可能な関数の完全な参照について詳しくは、ヘルパー関数、日時関数、文字列関数、配列関数を参照してください。
日時のレシピ date-time-recipes
レシピ 1 - 読み取り可能な形式での現在の日付の表示 recipe-current-date
formatDate と getCurrentZonedDateTime() を使用して、今日の日付を任意の形式でレンダリングします。
{%= formatDate(getCurrentZonedDateTime(), "MMMM dd, yyyy") %}
出力(例):April 11, 2026
一般的な形式パターン:
"dd/MM/yyyy"11/04/2026"MM/dd/yyyy"04/11/2026"EEEE, MMMM dd"Saturday, April 11"yyyy-MM-dd"2026-04-11レシピ 2 - 有効期限またはイベント日までのカウントダウン recipe-countdown
dateDiff を使用して、プロファイル日付属性までの残り日数を計算し、動的にレンダリングします。
出力(例):Your reward points expire in 7 days. Use them before they're gone!
レシピ 3 - 動的な終了日の X 日前 recipe-days-before
プロファイル属性の X 日前の日付を計算(例:コンテンツや件名で参照)するには、負のオフセットを指定して addDays を使用します。
{%= formatDate(addDays(stringToDate(profile.subscription.endDate), -7), "MMMM dd, yyyy") %}
出力(例):April 04, 2026 (4月11日(PT)の 7 日前)
また、固定時間(例:午前 9 時)を設定するには、setHours と組み合わせます。
{%= formatDate(setHours(addDays(stringToDate(profile.subscription.endDate), -7), 9), "dd/MM/yyyy HH:mm") %}
レシピ 4 - HH:MM としてのみの現在の時間の表示 recipe-time-only
extractHours と extractMinutes を使用して時間部分のみを表示します。その際、分については先頭のゼロを補完する処理を行います。
出力(例):Your appointment is at 14:05.
レシピ 5 - 週末と平日の区別 recipe-weekend
dayOfWeek を使用して、曜日に基づいてコンテンツを適応させます。 関数は、1(月曜日)から 7(日曜日)までの値を返します。 単一の = 演算子を使用します(== ではなく PQL 構文)。
dayOfWeek() は、曜日に基づいて コンテンツ を適応させます。 曜日に基づいてジャーニー内で異なるプロファイルをルーティングする場合、ジャーニーの条件アクティビティでビルトインの「時間条件 → 曜日」オプションを使用します。 詳細情報配列とループのレシピ array-recipes
レシピ 6 - プロファイル配列からのすべての項目の一覧表示 recipe-list-items
{{#each}} を使用してプロファイル配列を反復処理し、各項目をレンダリングします。 これは、パーソナライゼーションエディター(電子メール、モバイル、プッシュ通知)でのみ使用できます。
出力(例):
- Running shoes: 89€
- Water bottle: 15€
- Gym bag: 45€
{{#each}} は、ジャーニー条件アクティビティではサポートされていません。 条件の配列フィルタリングの場合、コレクション管理関数を使用します。レシピ 7 - 価格で配列から上位 N 個の項目の表示 recipe-first-n
topN を使用して、数値フィールドで上位 N 個の項目を並べ替えて取得します。 topN は PQL 関数なので、最初に {% let %} を使用して変数に割り当て、次に {{#each}} でループします。
topN(profile.orders, price, 3) は、注文を price の降順で並べ替え、上位 3 個を返します。元の配列の順序で最初の 3 個をシンプルに返すわけではありません。または、head を使用して、上位の項目を 1 つのみ取得します。
{%= head(profile.purchases.recentItems).name %}
レシピ 8 - 配列項目ごとに条件付きでのコンテンツのレンダリング recipe-conditional-loop
{{#each}} 内の {%#if%} を使用して、一致する項目に対してのみ出力をレンダリングします。 PQL 評価基準が条件内の属性参照を解決できるように、as |order| を使用してループエイリアスを定義します。
this.status は Handlebars 式では機能しますが、{%#if%} 内の PQL 評価基準では解決されません。 名前付きのループエイリアス(例:order)を使用すると、属性を Handlebars と PQL の両方のコンテキストで使用できます。文字列と書式設定のレシピ string-recipes
レシピ 9 - replaceAll を使用した文字列のクリーニングと再利用 recipe-replaceall-reuse
replaceAll は新しい値を返します。元の値は変更されません。 {% let %} を使用して結果を格納し、関数呼び出しを繰り返さずに複数回参照します。
出力(例):
Hi John,
Your exclusive code is: WELCOME-JOHN
レシピ 10 - JSON 出力での値の二重引用符 recipe-json-quotes
文字列内にリテラルな二重引用符を含めるには(例:カスタムペイロード用の JSON の生成)、バックスラッシュ(\")でエスケープします。
出力:{ "greeting": "Hello \"John\"" }
レシピ 11 - すべて大文字での日付コンポーネントの書式設定 recipe-uppercase-date
formatDate と upperCase を組み合わせて、月や曜日の名前をすべて大文字でレンダリングします。
{%= upperCase(formatDate(getCurrentZonedDateTime(), "MMMM")) %}
出力(例):APRIL
すべて大文字の日付文字列の場合:
{%= upperCase(formatDate(profile.person.birthDateTime, "EEEE MMMM dd yyyy")) %}
出力(例):WEDNESDAY JANUARY 01 2020
条件付きロジックのレシピ conditional-recipes
レシピ 12 - パーソナライズされたコンテンツの IF/ELSEIF/ELSE recipe-if-elseif
複数の分岐の条件付きロジックには、{%#if%}、{%else if%}、{%else%} を使用します。 このパターンは、メールコンテンツとフラグメントで機能します。
レシピ 13 - Null セーフ属性表示 recipe-null-safe
プロファイル属性が null または欠落していることがある場合、空の値のレンダリングを回避するには、条件付きフォールバックを使用します。
または、isEmpty を使用した三項演算子スタイルのパターンをインラインで記述します。
PQL エッジケースのレシピ pql-edge-cases
レシピ 14 - ハイフン付きの属性キーの参照 recipe-hyphenated-key
XDM スキーマフィールド名にハイフン(例:order-total、event-type)が含まれている場合は、ハイフンが減算演算子として解釈されないように、PQL 式内でバックティックで囲みます。
{%= profile.events.`order-total` > 100 %}
{%= ... %})内でのみサポートされています。 これらは、通常の Handlebars の補間({{...}})では使用できません。 ハイフンを含むフィールド値を直接レンダリングする必要がある場合は、最初に PQL 式で評価するか、{% let %} を使用して変数に格納します。レシピ 15 - コンテキスト属性での数値イベント ID の参照 recipe-numeric-event-id
ID が数値文字列(例:1697323153)であるジャーニーコンテキストイベントを使用する場合は、ID をバックティックで囲み、toDateTime() および formatDate() と共に {% let %} を使用します。
出力(例):Your appointment: 18/03/2026 14:30
レシピ 16 - タイプ強制:文字列フィールドと数値の比較 recipe-type-coercion
PQL は強くタイプ付けされています。 プロファイルフィールドが文字列として格納されているが、数値として比較する必要がある場合は、最初に stringToNumber() で変換します。
{%= stringToNumber(profile.loyalty.pointsBalance) > 500 %}
文字列として格納されるブール値フィールドの場合:
{%= 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