Recommendation design with mbox parameter | Community
Skip to main content
Urs_Boller
Community Advisor
Community Advisor
December 10, 2022
Solved

Recommendation design with mbox parameter

  • December 10, 2022
  • 3 replies
  • 2340 views

we are trying to setup a new design for recommendations. everything works fine appart from language split.

 

goal: display different attributes based on page language

 

setup: in the target call we added a new parameter "language" that can be used in the design

 

problem: everything works fine and the mbox parameter gets populated correctly. however, we are not able to create any if-then-else clause based on this mbox parameter. whatever we tried, it failed.

 

what it might look like is something like this:

---

#if( \${mbox.language} == "en" )

  ## layout for en here

#else

  ## other layout here

#end

---

 

question: anybody has a working example of an "if-then-else" using a mbox parameter?

 

thanks for any help!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Urs_Boller

After a long time and help from Customer Care here is the final solution.

  1. Profile Script: Use the profile script to fetch the mbox-parameter and save in a profile variable. the code could be something like this
    return mbox.param("myParameter");​it's just a short version, you can improve this by adding error handling (check if exists or fetch from profile instead).
    Attention: do NOT use camelCase for your variable (or it wont work later on), so better "my_parameter" and not "myParameter"
     
  2. Reco Design: in your recommendation design you can now access the profile variable and do an if-clause like this
    #set($e=$profile.get("user.my_script_variable")) #if($e== 'my_desired_value') TRUE #end #if($e!= 'my_desired_value') FALSE #end​it is just a simple example to give you an idea about the structure and coding..

hope that helps 🙂

3 replies

kchaitanya
Level 3
December 12, 2022

Don't have an exact answer to the right code to use in design, but can't you use your language mbox parameter as filtering condition in audience and qualify different users based on the language to different design experiences (you will have to setup Recommendations as an offer in XT activity). 

Urs_Boller
Community Advisor
Community Advisor
December 12, 2022

Hi @kchaitanya thanks for the reply.

the idea for audiences is what we use currently (but means we have to maintain a lot of designs just with a small change). And this only works if the difference in the design is solely based on the mbox parameter.

but think of a design where you want to add something based on mbox parameter AND product attribute. as an example, display a batch (sign) for a special offer if the user has a certain membership status AND the product is allowed to be a special offer... this would mean we need a way to do the if-statement in the design.

I still hope somebody has an example ...

Community Advisor
February 7, 2023

We do not use the else statement, rather we use multiple #if #end statements. We have a profile script that sets user.month based on current month when request is made and then we read that month in the design to alter the response:

 

#set($mboxCat = "M-\${user.month}-\${user.year}-" + "$criteria.title")

 

 

Urs_Boller
Community Advisor
Community Advisor
February 8, 2023

Hi @evidana 

thanks for the reply. with your solution are you able to do an if-clause?

whatever I tried, I was not able to do an if-clause like this:

 

#if ( $mboxCat == "M-02-2003-test")

 

can you provide an example on how to use your variable in an if-statement?

thanks!

 

Urs_Boller
Community Advisor
Urs_BollerCommunity AdvisorAuthorAccepted solution
Community Advisor
March 16, 2023

After a long time and help from Customer Care here is the final solution.

  1. Profile Script: Use the profile script to fetch the mbox-parameter and save in a profile variable. the code could be something like this
    return mbox.param("myParameter");​it's just a short version, you can improve this by adding error handling (check if exists or fetch from profile instead).
    Attention: do NOT use camelCase for your variable (or it wont work later on), so better "my_parameter" and not "myParameter"
     
  2. Reco Design: in your recommendation design you can now access the profile variable and do an if-clause like this
    #set($e=$profile.get("user.my_script_variable")) #if($e== 'my_desired_value') TRUE #end #if($e!= 'my_desired_value') FALSE #end​it is just a simple example to give you an idea about the structure and coding..

hope that helps 🙂

June 21, 2024

Hey!
I found this post while investigating possible solutions because I was facing the same challenge.

 

I found out, that (maybe in the meantime) it became possible to simply access box-parameters within the design simply via 

${mbox.myparameter}

 which is kind of nice!

The "Parameter to ProfileScript to user profile" felt a little detour-like.
This seems to be a more straightforward solution and works fine for me.

Maybe this helps someone in need...