Create Fredhopper Trigger Types Programatically

Reading the docs, you would be led to believe that creating Fredhopper triggers was a matter of editing the trigger-types.xml file. It is however also possible to do this programatically – a trick that can come in handy should you not have access to that file on Production, or you wish to manage your triggers through automation.

The SmartTarget developers have created some handy helper classes:

  • com.tridion.smarttarget.triggers.TriggerTypesHelper – Can be used to create/retrieve Trigger Types
  • com.tridion.smarttarget.utils.LocalizationHelper – Can be used to manage Trigger Labels – the display text you see in the SmartTarget UI when selecting a value

In my implementation I actually packaged a JSP page up with the deployer war file (which already had the required SmartTarget configuration files needed for the SmartTarget API), which we call manually on every environment to create new triggers.

The URL parameters which should be added when requesting the JSP are as follows:

  • name – The trigger name
  • urlParam – The trigger url parameter
  • type – (Optional) The trigger type : text (default), number, date or boolean
  • values – (Optional) For triggers where the values are selected from a list, a comma delimited list of values
  • labels – (Optional) For triggers where the values are selected from a list, a comma delimited list of display values
  • multi – (Optional) When true (default is false) The trigger type is created as multiselect

In the future we might hook into the CMS, so we could, for example create a trigger type based on a category in Tridion (using the keyword keys as the trigger values, and title/descriptions as the trigger value labels) via a GUI extension (Category right click -> Sync Trigger Type). This would be the last step in removing IT involvement in trigger management.

One thought on “Create Fredhopper Trigger Types Programatically

  1. Thanks for posting this, Will. Do you happen to have a sample request for creating trigger types through the API? I ask b/c the only references that I’ve found for the objects in this article are in JSP. All of our stuff is in C#, so I’m hoping to be able to provide this capability using some custom classes in C#

    The only examples that I have found, are the examples for renaming the trigger-type (providing an alias) or adjusting a trigger-type value.

    Your help would be greatly appreciated!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>