1

I have Sitecore CDP Interactive Experience defined based off Decision Model that returns an offer. On offer data I have context parameter ${guest.firstname} defined but its not resolving its value and returning it as-is in the experience response.

JSON response:

{
  "decisionOffers": [
    {
      "ref": "616b2261-9cd1-48a1-94c5-e7d00f89b4d5",
      "name": "Harsh-50-USD-Discount",
      "description": "USD 50 Discount",
      "status": "ACTIVE",
      "attributes": {
        "imageurl": "https://via.placeholder.com/150/A0A0A0/FFFFFF/?text=$+50+Off",
        "name": "50% off on Apple Watches ${guest.firstname}"
      }
    }
  ]
}

Should this resolve by itself before returning response and how?

Image:

Sitecore CDP Experience Response

1
  • I've just updated my answer with the response from Sitecore Support - basically this functionality is a leftover from an old deprecated feature and will be removed from the UI sitecore.stackexchange.com/a/33786/4825. However, my and x3mxray's workarounds are still valid and will continue working.
    – Anna Gevel
    Mar 15 at 9:44

2 Answers 2

1

I`ve faced the same issue. Looks like a bug.

My workaround was to move context parameters out of offer:

{
<#if (offers)??>
  "decisionOffers": ${toJSON(offers)},
</#if>
"firstName": "${guest.firstName!}"
}

Experience response is:

{
  "decisionOffers": [
    {
      "ref": "fcde595f-fd78-41db-8b0e-23b5af1f1185",
      "name": "Offer ",
      "description": "Offer ",
      "status": "ACTIVE",
      "attributes": {
        "imageUrl": "https://icycoupons.com/img/single-offer/womensbest.jpg",
        "title": "Dear ${guest.firstname}, 40% Off Best Coupon!",
        "description": "Save money on things you want with a Women's Best promo code or coupon. Join the Women's Best Rewards Club for Birthday Offers, Early Access to Limited Editions & Surprise Gifts with Every Purchase.",
        "linkUrl": "https://by.wildberries.ru/brands/womens-store"
      }
    }
  ],
  "firstName": "Denis"
}

As you can see substitution doesn`t work inside offer, but works outside. And you can substitute your variablr in HTML markup, like this:

<h1>Dear {{firstName}},</h1>
{{#decisionOffers}}
  {{#attributes}}
    <div class="img-container">
        <div class="img-container__image" style='background-image: url("{{imageUrl}}");'></div>
    </div>
    <div class="bx-transition-card__body">
       
        <h3>[[Title | string | {{title}} | {required:true, group: Title, order: 1}]]</h3>
        <p>[[Description | text | {{description}} | {required:true, group: Description, order: 1}]]</p>
        <div class="options-container">
            <a id="bx-transition-card--secondary" class="options-container__secondary">[[Dismiss Text | string | No Thanks | {required:true, group: Secondary Button, order: 1}]]</a>
            <a id="bx-transition-card--primary" class="options-container__primary" href="{{linkUrl}}">[[CTA Text | string | Yes Please | {required:true, group: CTA Button, order: 1}]]</a>
        </div>
    </div>
    {{/attributes}}
{{/decisionOffers}}
</div>

enter image description here

1

Update on 15/03/2023

I raised this with Sitecore Support and got the following response:

Functionality related to context parameters in offers is a leftover from the old Engage 1 feature which is now deprecated. Context parameters for offers were not designed to work with Freemarker or Decision Tables. Thus, it was decided to remove all UI elements that contain references to this functionality as well as update the documentation to avoid further confusion.

Nevertheless, since you have an interest in this functionality, I submitted a feature request to our development team regarding the same.

Workaround

This is a workaround I found while trying to resolve the same problem - a context parameter in offer was not replaced automatically and instead it was returned as simple text:

Welcome ${guest.firstName}

I managed to make it work by using the ?interpret built-in method that exists in FreeMarker. It can execute string variables as FreeMarker templates. Here is an example of how an offer title can be accessed and interpreted in a full stack experience:

{
<#if (offers)??>
    "offer": {
        "title": "<@(offers[0].attributes.Title)?interpret />",
        "description": "<@(offers[0].attributes.Description)?interpret />",
        "imageUrl": "${offers[0].attributes.ImageUrl}"
    }
</#if>
}

This is just a temporary workaround as I would expect Sitecore CDP/Personalize to replace the context variables in offers automatically.

Another thing I noticed is that Offers editing UI suggests variables ${guest.firstname} and ${guest.lastname} in lowercase while FreeMarker template expects them in camel case.

Offers editing UI

So I had to tweak the variable manually like this to use the correct field name: ${guest.firstName}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.