3

I am setting up some custom Trigger Types for a SmartTarget implementation, whose values should be selected from a list. As these trigger types will also have a relationship with the "tagging" of content (so be used to drive content selection and filtering) I first thought of using keywords to manage the values.

However, when I implemented the Trigger Type as being of type Keyword (as described in docs) I was not - as I would have expected - able to specify a particular category to link to the trigger type, instead any keyword could be selected. This results in a rather clunky user experience, as they have to do additional clicks and know which category they should be selecting the values from.

Secondly I noticed that I was not able to select multiple keywords, so I could not build an OR relationship in the promotion.

Given that I want to be able to add trigger values without IT intervention (updating config files etc.), but want to have a clear user experience and have OR relationships, what is the best solution for these types of list trigger types?

Of additional interest is if it is possible to differentiate display value with underlying ID/code/key in any way - the trigger-types.xml file doesn't seem to support this - could a GUI extension help?

2

1 Answer 1

2

It's possible to do both of those things using the Fredhopper REST service. The labels need to be specified separately using a different endpoint.

It's a little complicated, so I usually recommend that you use the LocalizationHelper class from the SmartTarget Java API. That is what SmartTarget uses to keep the list of Audience Manager Segments updated and showing the title of them instead of the URI that it uses internally.

Here is some sample code taken from another, similar question:

// Supply user-friendly titles for the trigger values (optional)
LocalizationHelper localizationHelper = new LocalizationHelper();
// productValuesAndLabels is a HashMap<String, String> of values and their titles
localizationHelper.addTriggerTypeLabels("ProductType", productValuesAndLabels);

// Add or update the actual trigger
TriggerTypesHelper triggerTypesHelper = new TriggerTypesHelper();
TriggerType triggerType = triggerTypesHelper.createTriggerType("ProductType", "text", "my_product_type", triggerValues);

boolean success = triggerTypesHelper.addTriggerType(triggerType);
2
  • Would it be bad form to get a "friendly" label or identifier (ID/code/key) from the Keyword itself? Commented Jul 17, 2015 at 16:39
  • I don't see why it would be. Seems perfectly reasonable. Commented Jul 22, 2015 at 9:05

Your Answer

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

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