Leverage fragments in decision policies fragments
Decision items support two types of fragment content that can be leveraged when authoring messages within a decision policy:
- Journey Optimizer content fragments — reusable expression fragments created in Journey Optimizer and added to the decision item’s Fragments section. Learn more about AJO content fragments
- AEM Content Fragments — content authored in Adobe Experience Manager, mapped to the decision item’s attributes, and selected in the personalization editor by key name. Learn how to tie an AEM Content Fragment to a decision item
Journey Optimizer content fragments ajo-fragments
If your decision policy contains decision items including AJO content fragments, you can leverage these fragments when authoring a message within the decision policy across all channels where Decisioning is available (code-based experience, Email, Push, SMS, and journeys).
For example, let’s say you want to display different contents for several mobile device models. Add the specified fragments, each pertaining to a different phone model, to the decision item you are using in the decision policy. Learn how to add fragments to a decision item.
Once done, you can use either one of the following methods:
Simply copy-paste the code block below into the decision policy code. Replace variable with the fragment ID and placement with the fragment reference key:
| code language-handlebars |
|---|
|
-
Navigate to the Helper functions and add the Let function
{% let variable = expression %} {{variable}}to the code pane, where you can declare the variable for your fragment.
-
Use the Map > Get function
{%= get(map, string) %}to build your expression. The map is the fragment referenced in the decision item. The string can be the device model you entered in the decision item as the Fragment reference key.
-
You can also use a contextual attribute which would contain this device model ID.
-
Add the variable that you chose for your fragment as the fragment ID.
The fragment ID and reference key will be selected from the decision item’s Fragments section.
required=false flag is used so the fragment is skipped instead. Learn more about temporarily unavailable fragmentsUsage and guardrails fragments-guardrails
The following guardrails apply specifically to AJO content fragments used in decision items.
Decision item attributes and contextual attributes are not supported by default in Journey Optimizer fragments. However, you can use global variables instead, such as described below.
Let’s say you want to use the sport variable in your fragment.
-
Reference this variable in the fragment, for example:
code language-text Elevate your practice with new {{sport}} gear! -
Define the variable with the Let function within the decision policy block. In the example below, sport is defined with the decision item attribute:
code language-handlebars {#each decisionPolicy.13e1d23d-b8a7-4f71-a32e-d833c51361e0.items as |item|}} {% let sport = item._cjmstage.value %} {{fragment id = get(item._experience.decisioning.offeritem.contentReferencesMap, "placement1").id }} {{/each}}
-
Due to the dynamic nature of these fragments, when used in a campaign, message validation during campaign content creation is skipped for fragments referenced in decision items.
-
The validation of the fragment content happens only during the fragment creation and publication.
-
For JSON-type expression fragments, the content is syntactically validated upon saving the fragment. Validation errors are displayed as alerts.
At runtime, the campaign content (including fragment content from decision items) is validated. In case of a validation failure, the campaign will not get rendered.
When journeys or campaigns reference fragments attached to decision items, there can be short synchronization delays before updated fragments are available on Edge.
To avoid failures when a fragment is temporarily unavailable, fragments now have the required flag set to false by default so that they are skipped instead of causing the journey or campaign to fail.
This means that if the fragment is temporarily unavailable on Edge, it is simply ignored. If the fragment is available, it renders normally.
Example
If your decision policy qualifies for two offers and each has a fragment—for example, “20% off” and “30% off”—and the second fragment is temporarily unavailable, with required=false the system renders the available offer (20% off) and skips the other fragment (30% off) instead of failing the journey or campaign. This improves reliability when content is still synchronizing.
required flag to true. However, if a fragment is temporarily missing, it may cause journey or campaign rendering to fail.AEM Content Fragments aem-fragments-decisioning
Before leveraging AEM Content Fragments in a decision policy, make sure you have:
- Created your Content Fragment in Adobe Experience Manager and tagged it with
ajo-enabled:{OrgId}/{SandboxName}so that it is discoverable by Journey Optimizer. Learn how to create and assign a tag - Tied the fragment to the AEM Fragments section of the offer item by assigning it a unique reference name. Learn how to tie an AEM Content Fragment to a decision item
In the personalization editor, all AEM Content Fragments associated with the decision items selected by the policy are available. One folder appears per fragment key name.
In this example, the decision policy includes two decision items that have AEM fragments tied to them through their reference name.
-
Click the + button to add the desired fragment into your expression.
Since a single reference name may have multiple fragments tied to it across different offer items, Decisioning determines the best one to deliver to each customer based on the decision policy’s ranking criteria.
-
Once the fragment has been selected, you can leverage its attributes, such as image URLs, text fields, or other content, and use Decisioning to surface the right content to the right customer at the right time.
-
Before activating your campaign or journey, you can use Simulate content to preview how AEM Content Fragment field values will render for a specific test profile. Learn more on simulating content