このページ: Adobe Journey Optimizer の upperCase、each、if ヘルパー関数を使用してメール本文をパーソナライズする、買い物かごの放棄のユースケースについて説明します。
この例では、メールメッセージの本文をパーソナライズします。 このメッセージは、買い物かごに商品が残っているが購入を完了していない顧客をターゲットにします。
次のタイプのヘルパー関数を使用します。
➡️ ヘルパー関数の使用方法について詳しくは、このビデオを参照してください。
開始する前に、次の要素の設定方法を理解しておく必要があります。
次の手順に従います。
手順 1:最初のイベントと関連ジャーニーの作成 create-context
買い物かごの内容は、ジャーニーからのコンテキスト情報です。 したがって、買い物かご固有の情報をメールに追加する前に、最初のイベントとメールをジャーニーに追加する必要があります。
-
スキーマに
productListItems配列が含まれるイベントを作成します。 -
この配列のすべてのフィールドを、このイベントのペイロードフィールドとして定義します。
製品リスト項目データタイプについて詳しくは、Adobe Experience Platform ドキュメントを参照してください。
-
このイベントで開始されるジャーニーを作成します。
-
ジャーニーに メール アクティビティを追加します。
手順 2: メールの作成 configure-email
-
メールアクティビティで、「コンテンツを編集」をクリックしたあと、「E メールデザイナー」をクリックします。
-
E メールデザイナーホームページの左側のパレットから、3 つの構造コンポーネントをメッセージの本文にドラッグ&ドロップします。
-
HTML コンテンツコンポーネントを、それぞれの新規構造コンポーネントにドラッグ&ドロップします。
手順 3: 顧客の名(大文字)の挿入 uppercase-function
-
E メールデザイナーのホームページで、顧客の名を追加する HTML コンポーネントをクリックします。
-
コンテキストツールバーで、「ソースコードを表示」をクリックします。
-
HTML を編集ウィンドウで、
upperCase文字列関数を追加します。-
左側のメニューで、「ヘルパー関数」を選択します。
-
検索フィールドを使用して、「uppercase」を検索します。
-
検索結果から、
upperCase関数を追加します。 それには、{%= upperCase(string) %}: stringの横のプラス記号(+)をクリックします。式エディターには、次の式が表示されます。
code language-handlebars {%= upperCase(string) %}
-
-
式から「string」プレースホルダーを削除します。
-
名トークンを追加します。
-
左側のメニューで、「プロファイル属性」を選択します。
-
人物/姓名を選択します。
-
式に 名 トークンを追加します。
式エディターには、次の式が表示されます。
code language-handlebars {%= upperCase(profile.person.name.firstName) %}
人物名データタイプについて詳しくは、Adobe Experience Platform ドキュメントを参照してください。
-
-
「 検証」をクリックしてから、「保存」をクリックします。
-
メッセージを保存します。
手順 4:買い物かご内の商品リストの挿入 each-helper
この手順では、イベントデータの反復処理を示します。 様々なデータソース(イベント、カスタムアクション応答、その他のコンテキストデータ)を反復処理する包括的な例について詳しくは、Handlebars を使用したコンテキストデータの反復処理を参照してください。
-
メッセージコンテンツを再度開きます。
-
E メールデザイナーのホームページで、買い物かごの内容を一覧表示する HTML コンポーネントをクリックします。
-
コンテキストツールバーで、「ソースコードを表示」をクリックします。
-
HTML を編集ウィンドウで、
eachヘルパーを追加します。-
左側のメニューで、「ヘルパー関数」を選択します。
-
検索フィールドを使用して、「each」を検索します。
-
検索結果から、
eachヘルパーを追加します。式エディターには、次の式が表示されます。
code language-handlebars {{#each someArray as |variable|}} {{/each}}
-
-
式に
productListItems配列を追加します。-
式から「someArray」プレースホルダーを削除します。
-
左側のメニューで、「コンテキスト属性」を選択します。
コンテキスト属性は、ジャーニーコンテキストがメッセージに渡された後でのみ使用できます。
-
Journey Optimizer/イベント/event_name を選択し、productListItems ノードを展開します。
この例では、event_name はイベントの名前を表します。
-
式に 製品 トークンを追加します。
式エディターには、次の式が表示されます。
code language-handlebars {{#each context.journey.events.event_ID.productListItems.product as |variable|}} {{/each}}この例では、event_ID はイベントの ID を表します。
-
式を次のように変更します。
- 「.product」文字列を削除します。
- 「variable」プレースホルダーを「product」に置き換えます。
次の例は、変更された式を示しています。
code language-handlebars {{#each context.journey.events.event_ID.productListItems as |product|}}
-
-
次のコードを、
{{#each}}開始タグと{{/each}}終了タグの間に貼り付けます。code language-html <table> <tbody> <tr> <td><b>#name</b></td> <td><b>#quantity</b></td> <td><b>$#priceTotal</b></td> </tr> </tbody> </table> -
商品名、数量および価格のパーソナライゼーショントークンを追加します。
- HTML テーブルからプレースホルダー「#name」を削除します。
- 前の検索結果から、名前トークンを式に追加します。
次の手順を 2 回繰り返します。
- プレースホルダー「#quantity」を 数量 トークンに置き換えます。
- プレースホルダー「#priceTotal」を 合計価格 トークンに置き換えます。
次の例は、変更された式を示しています。
code language-handlebars {{#each context.journey.events.event_ID.productListItems as |product|}} <table> <tbody> <tr> <td><b>{{product.name}}</b></td> <td><b>{{product.quantity}}</b></td> <td><b>${{product.priceTotal}}</b></td> </tr> </tbody> </table> {{/each}} -
「検証」をクリックしてから、「保存」をクリックします。
手順 5:製品固有のメモの挿入 if-helper
-
E メールデザイナーのホームページで、メモを挿入する HTML コンポーネントをクリックします。
-
コンテキストツールバーで、「ソースコードを表示」をクリックします。
-
HTML を編集ウィンドウで、
ifヘルパーを追加します。-
左側のメニューで、「ヘルパー関数」を選択します。
-
検索フィールドを使用して、「if」を検索します。
-
検索結果から、
ifヘルパーを追加します。式エディターには、次の式が表示されます。
code language-handlebars {%#if condition1%} render_1 {%else if condition2%} render_2 {%else%} default_render {%/if%}
-
-
式から次の条件を削除します。
code language-handlebars {%else if condition2%} render_2次の例は、変更された式を示しています。
code language-handlebars {%#if condition1%} render_1 {%else%} default_render {%/if%} -
製品名トークンを条件に追加します。
-
式から「condition1」プレースホルダーを削除します。
-
左側のメニューで、「コンテキスト属性」を選択します。
-
Journey Orchestration/イベント/event_name を選択し、productListItems ノードを展開します。
この例では、event_name はイベントの名前を表します。
-
式に 名前 トークンを追加します。
式エディターには、次の式が表示されます。
code language-handlebars {%#if context.journey.events.`event_ID`.productListItems.name%} render_1 {%else%} default_render {%/if%}
-
-
式を次のように変更します。
-
式エディターで、
nameトークンの後に製品名を指定します。次の構文を使用します。ここで、product_name は製品の名前を表します。
code language-javascript = "product_name"この例では、製品名は「Juno Jacket」です。
code language-handlebars {%#if context.journey.events.`event_ID`.productListItems.name = "Juno Jacket" %} render_1 {%else%} default_render {%/if%} -
「render_1」プレースホルダーを注記のテキストに置き換えます。
例:
code language-handlebars {%#if context.journey.events.`event_ID`.productListItems.name = "Juno Jacket" %} Due to longer than usual lead times on the Juno Jacket, please expect item to ship two weeks after purchase. {%else%} default_render {%/if%} -
式から「default_render」プレースホルダーを削除します。
-
-
「 検証」をクリックしてから、「保存」をクリックします。
-
メッセージを保存します。
手順 6:ジャーニーのテストと公開 test-and-publish
-
「テスト」切替スイッチをオンにしてから、「イベントをトリガー」をクリックします。
-
イベント設定ウィンドウで、入力値を入力し、「送信」をクリックします。
テストモードは、テストプロファイルでのみ機能します。
メールがテストプロファイルのアドレスに送信されます。
この例では、Juno Jacket に関するメモがメールに含まれています。これは、この製品が買い物かごに入っているからです。
-
エラーがないことを確認し、ジャーニーを公開します。
関連トピック related-topics
Handlebars 関数 handlebars
ユースケース use-case
チュートリアルビデオ video
ヘルパー関数の使用方法を説明します。
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 use case shows how to personalize the body of a cart abandonment email in a journey with the
upperCasestring function, theeachhelper and theifhelper.
Intents:
- Personalize the body of an email message that targets customers who have left items in their shopping cart but have not completed their purchase.
- Insert the customer’s first name in capital letters with the
upperCasestring function and the First name token of the Profile attributes. - List the items that are in the cart with the
eachhelper and theproductListItemsarray of the journey event. - Insert a product-specific note with the
ifhelper when the related product is in the cart. - Test the journey with the Test toggle and Trigger an event, verify that there is no error, then publish the journey.
Glossary:
- Cart content: Contextual information from the journey, used in this use case to list the items in the cart and to insert a product-specific note. (product-specific)
upperCasestring function: The function used in this use case to insert the customer’s first name in capital letters. (product-specific)eachhelper: The helper used in this use case to list the items that are in the cart. (product-specific)ifhelper: The helper used in this use case to insert a product-specific note if the related product is in the cart. (product-specific)- event_name and event_ID: In the examples of this use case, event_name represents the name of your event and event_ID represents the ID of your event.
Guardrails:
- Contextual attributes are available only after the journey context has been passed to the message.
- The test mode works only with test profiles.
Prerequisites and permissions:
- Before you start, ensure you know how to configure a unitary event, a journey that starts with an event, an email message in your journey and the body of an email.
- You must add an initial event and the email to a journey before you can add cart-specific information to the email.
Terminology:
- Canonical name: Adobe Journey Optimizer — Acronym: AJO — variants: Journey Optimizer
- Canonical name: Adobe Experience Platform — Acronym: AEP
FAQ:
- Why must the event and the email be added to a journey before adding cart-specific information? The cart content is contextual information from the journey.
- When are Contextual attributes available in the Edit HTML window? Contextual attributes are available only after the journey context has been passed to the message.
- How do you specify the product in the
ifcondition? In the Expression editor, specify the product name after thenametoken with the syntax= "product_name", where product_name represents the name of your product. - Which profiles does the test mode work with? The test mode works only with test profiles, and the email is sent to the address of the test profile.
- What do event_name and event_ID represent in the expressions? event_name represents the name of your event and event_ID represents the ID of your event.
Examples:
- First name in capital letters:
{%= upperCase(profile.person.name.firstName) %}. - List of cart items:
{{#each context.journey.events.event_ID.productListItems as |product|}}wraps an HTML table with the tokens{{product.name}},{{product.quantity}}and${{product.priceTotal}}, closed by{{/each}}. - Product-specific note, where the product name is “Juno Jacket”:
{%#if context.journey.events.`event_ID`.productListItems.name = "Juno Jacket" %}followed by the note “Due to longer than usual lead times on the Juno Jacket, please expect item to ship two weeks after purchase.” and{%/if%}. In the test, the email contains the note about the Juno Jacket because this product is in the cart.
Related pages:
- For the
upperCasestring function: String functions - For the
eachandifhelpers: Helpers - For comprehensive examples of iterating over different data sources (events, custom action responses, and other contextual data): Iterate over contextual data with Handlebars
- To configure a unitary event: Work with journey events
- To configure a journey that starts with an event: Design your journey
- To configure an email message in your journey: Create an email
- To configure the body of an email: Design content from scratch in Journey Optimizer
- For another personalization use case: Personalization with profile information, context, and offer
- For a personalization use case with a decision-based offer: Personalization with decision-based offer
Personas:
- developer: Can create an event whose schema includes the
productListItemsarray and define all the fields from this array as payload fields. Can insert the customer’s first name in capital letters with{%= upperCase(profile.person.name.firstName) %}. Can list the cart items with{{#each context.journey.events.event_ID.productListItems as |product|}}and the{{product.name}},{{product.quantity}}and{{product.priceTotal}}tokens. Can insert a product-specific note with theifhelper and the syntax= "product_name"after thenametoken. The page states that Contextual attributes are available only after the journey context has been passed to the message. Where: “Examples”.
Onboarding:
- Level: Intermediate
- First minimal step: Create an event whose schema includes the
productListItemsarray. - Success check: The email is sent to the address of the test profile.