Expand my Community achievements bar.

SOLVED

Recommendation design with mbox parameter

Avatar

Community Advisor

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!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

5 Replies

Avatar

Level 4

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). 

Avatar

Community Advisor

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 ...

Avatar

Community Advisor

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")

 

 

Avatar

Community Advisor

Hi @Eric_Vidana 

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!

 

Avatar

Correct answer by
Community Advisor

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