Campaign element task commands

Each trigger, target, and action has an associated task command called a campaign element task command. The task command performs the work associated with the campaign element. The campaign element template definition must specify which task command to use.

Task commands serve several functions, as described in the following table:
Functions of task commands for campaign elements
Task command function Method that is called in the task command Applies to triggers? Applies to targets? Applies to actions?
Validate the campaign element's parameters when the marketing activity is activated validateParameters Yes, if needed. Yes, if needed. Yes, if needed.
Perform the work when a customer reaches the campaign element in a marketing activity performExecute No Yes, mandatory. Yes, mandatory.
Forward triggers for processing once a day when the trigger type is a daily check. For more information, see tsbtypediaact.html.

Examples include the Customer Is In Segment trigger and the Customer Abandons Cart trigger.

forwardTriggersForProcessing Yes, if needed No No

Format of a task command

A campaign element task command must be a class that implements the MarketingCampaignElementTaskCmd interface.

To understand the format of a task command, review the following code sample. The sample is for an example customized target. The purpose of the target is to determine the level of support that a customer paid for, such as a gold, silver, or bronze level of support.

The following code sample is an example of the task command interface class that extends from the MarketingCampaignElementTaskCmd interface:

public interface CustomLevelOfSupportTargetTaskCmd extends MarketingCampaignElementTaskCmd {
  public final static String defaultCommandClassName =
  CustomLevelOfSupportTargetTaskCmdImpl.class.getName();
}
The following code sample is an example of a task command implementation that extends from the MarketingCampaignElementTaskCmdImpl class. The snippets with numbers to the left are explained in more detail after the sample:

public class CustomLevelOfSupportTargetTaskCmdImpl 
 extends MarketingCampaignElementTaskCmdImpl 
 implements CustomLevelOfSupportTargetTaskCmd {
	
private final static String PARAM_SUPPORT_LEVEL = "supportLevel";
private final static String SUPPORT_TYPE_IS_MISSING = "_ERR_SUPPORT_TYPE_IS_MISSING";
private static final Logger LOGGER = LoggingHelper.getLogger(CustomLevelOfSupportTargetTaskCmdImpl.class);
private final static String CLASSNAME = CustomLevelOfSupportTargetTaskCmdImpl.class.getName();

public CustomLevelOfSupportTargetTaskCmdImpl() {}

1 public void performExecute() {
       final String METHOD_NAME = "performExecute";
       if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
         LOGGER.entering(CLASSNAME, METHOD_NAME);
       }	 
       boolean rc = false;   

1a // get the parameters set in the DMELEMENTNVP table
     Hashtable parameters = getElementParameters();
     // example of getting one of the parameters
     String desiredSupportLevel = (String)parameters.get(PARAM_SUPPORT_LEVEL);

1b // determine if the customer meets the criteria of the target
	String actualSupportLevel = getSupportLevel(getRegisteredMemberIdForPersonalizationId());
       if (desiredSupportLevel.equals(actualSupportLevel)) {
         rc = true;
       }

1c // for a target, return true or false as is appropriate
       setReturnValue(rc);
       if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
         LOGGER.exiting(CLASSNAME, METHOD_NAME, result);
	}	
      }	

       public String getSupportLevel(Long memberId) {
         // go to the custom database table
         // and return the support level for the customer
         // TODO…
       }				  

2 public List validateParameters(Map elementParameters) {
      final String METHOD_NAME = "validateParameters";
      	
      if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
        LOGGER.entering(CLASSNAME, METHOD_NAME, elementParameters);
      }	
      	
      List validationErrors = new ArrayList();
      	
      Object supportLevel = elementParameters.get(PARAM_SUPPORT_LEVEL);
      if (supportLevel == null || supportLevel.toString().length() == 0) {
        ApplicationError validateError = new ApplicationError(
         ApplicationError.TYPE_GENERIC_ERROR,
         SUPPORT_TYPE_IS_MISSING,
         null, LOGGER.getResourceBundleName());
         validationErrors.add(validateError);
        }
       	
        if (LoggingHelper.isEntryExitTraceEnabled(LOGGER)) {
          LOGGER.exiting(CLASSNAME, METHOD_NAME, validationErrors);
        }		
        return validationErrors;
      } 
    }
  • 1 This snippet defines the performExecute method, which performs the evaluation work for the target and returns true or false:
    • 1a This snippet calls the getElementParameters method to get the parameters that the task command uses to complete the evaluation. The parameters are defined as arguments in the campaign element task command.
    • 1b This snippet evaluates whether the target should return true or false. For example, if the target is customers who have the Gold level of support, then the target returns true when the customer that is being evaluated has the Gold level of support.
    • 1c This snippet informs the marketing services whether the target returned true or false.
  • 2 This snippet defines the validateParameters method to validate the target parameters and return any errors.

Methods that are used in a campaign element task command

This table provides more details about the typical methods used in campaign element task commands for triggers, targets, and actions. For a full list and description of available methods for task commands, see MarketingCampaignElementTaskCmdImpl.
Campaign element Typical methods used
Trigger
  • forwardTriggersForProcessing: Required for daily check triggers only: this method finds all the customers that are associated with the trigger and forwards the trigger for processing for each customer. This happens once a day at 2:00 AM., by default. Each customer then participates in the associated dialog activity that day.
  • validateParameters: This method validates that the business user sets all the required name-value pairs for the campaign element in the user interface, and can return error messages to the business user. You can use other methods in the validateParameters method to help validate the campaign element, such as the validateCategory or validateProduct methods.
Target
  • performExecute: This method evaluates whether the customer meets the criteria of the target, for example, whether the customer belongs to the Preferred Customer customer segment. If so, the performExecute method returns true, and the customer passes the target and continues through the marketing activity. If the performExecute method returns false, then the customer does not pass the target. You can use other methods in the performExecute method to identify the customer, such as the getPersonalizationId, getMemberId, and getRegisteredMemberIdForPersonalizationId methods. You can also use other methods to get the information associated with the current request, such as the getTriggerParameters, getStoreId, and getUserDataForElement methods.
  • validateParameters: This method validates that the business user has set all the required name-value pairs for the campaign element in the user interface, and can return error messages to the business user. You can use other methods in the validateParameters method to help validate the campaign element, such as the validateCategory or validateProduct methods.
Action
  • performExecute: This method performs the action for the customer. For a web activity, the action is to display something to the customer in an e-Marketing Spot. For a dialog activity, the action can be many things, such as sending the customer an email or issuing the customer a coupon.
  • validateParameters: This method validates that the business user sets all the required name-value pairs for the campaign element in the user interface, and can return error messages to the business user. You can use other methods in the validateParameters method to help validate the campaign element, such as the validateCategory or validateProduct methods.