I have developed a custom trigger in SDL Smart Target 2014 and I am able to print the claim values in my application using AmbientDataContext. I want to pass the value of claim as a trigger to the Fredhopper query in the code below. When I fetch the list of triggers from the code below, it does not list my custom claim as trigger.I have defined a url-param for the same in my trigger-types.xml also.

    ClaimStore claims = AmbientDataContext.getCurrentClaimStore();
                if (claims != null) {

                        Map<URI, Object> x = claims.getAll();
                        out.print("<b>Printing Claims registered</b><br/><br/>");
                        for (Map.Entry<URI, Object> entry : x.entrySet()) {
                                out.println("\"KEY\"  " + entry.getKey() + " \"Value\"  "
                                                + entry.getValue() + "<br/><br/>");


                String triggers = AmbientDataHelper.getTriggers(claims);
                out.println("<b>Triggers retreived list is </b>" + triggers);

                ResultSet rs = query
                                .execute("fh_location=//catalog01/en_US/categories<{catalog01_tcm_0_1234_1}&st_region=Homepage Promotions",
                                                "", "&st_publication=tcm:0-1234-1&taf:claim:usertype:prof=Physicians");

 out.println("<br/><br/><b>No of Promotions fetched form QueryFactory approach are  </b>" + rs.getPromotions().size());

"taf:claim:usertype:prof" is the URI of my claim and user_prof is the url-param I have defined in the trigger-types.xml

I have tried by passing both values in the above code but I am unable to fetch the promotions based on the query. I have also made entry to the smarttarget_conf file in the Prefix section as below by replacing the ":" sign with "_" as in the dcumentation.


When I print the list of triggers as string in above code it displays a list of preconfigured triggers like browser and os but not my custom trigger.

Please provide me pointers on how can I register it as a claim.



Claim to trigger mapping

The first problem is in the mapping. You should map the "group" instead of the claim. So you want to map the "group" taf:claim:usertype to the prefix user.

Try this mapping:


This way the claim taf:claim:usertype:prof will be mapped to the trigger url-param user_prof.

Addition after Mark's Comment

Trigger definition on the webapp

If the list of triggers in your triggers variable still does not contain user_prof, then the trigger type definition in the webapp might not be right. For a claim to end up in a query it needs to be mapped in the smarttarget_conf.xml (see fist part of the answer) and it needs to exist in the trigger definition.

What the SmartTarget API in your webapp does is to map all the claims to triggers, and the then compare that list with Fredhopper's trigger type definition. If a mapped trigger does not exist in the trigger definition, then it is removed from the list. So, claims are mapped to triggers, compared with the trigger type definition and added to the Fredhopper query.

The webapp loads the trigger type definition from the Fredhopper indexer instance (configured in the Indexer element in smarttarget_conf.xml). Have a look at your Fredhopper indexer instance at this URL http://localhost:8180/fredhopper/config/trigger-types , this should contain your user_prof trigger.

You can inspect trigger type definition loaded by the webapp by looking at the claimstore and find the taf:claim:ambientdata:definedtriggertypes claim. If this claim does not contain the user_prof trigger it might be cached (get a new ADF session or restart the webapp) or it is not added correctly in Fredhopper.

Trigger configuration in Fredhopper

After updating the trigger-types.xml configuration on both indexer and query instances you need to reload the trigger types configuration in Fredhopper. Go to the Fredhopper indexer instance and query instance (in development you might not use a separate query instance) and reload the trigger types configuration. You can do this at the sysadmin url http://localhost:8180/fredhopper/sysadmin/ with the Reload trigger types configuration option.

  • Hi Jan, Thanks for the response. I've done the change and in the trigger-types.xml defined it as below. <trigger-type basetype="text" url-param="user_prof" name="User Speciality"><list-of-values multiselect="false"> <value>Nurse</value> </list-of-values> </trigger-type> But its not getting printed as part of the below code. String triggers = AmbientDataHelper.getTriggers(claims); I think that only when it is listed as a trigger, will it allow me to fire a query based on the user_prof trigger Kindly help me where I could check again Thanks Jan 22 '15 at 6:48
  • I added a second part and third part in the answer, check if the trigger types are loaded in Fredhopper, and if they end up in your webapp.
    – Jan H
    Jan 22 '15 at 8:38
  • Hi Jan, Many thanks for your pointers. I am able to resolve the issue. Thanks :) Jan 22 '15 at 12:55

Your Answer

