Develop > Presentation layer > Customize marketing > Marketing customization: Management Center > Customizing triggers, targets, and actions > Campaign element template definitions


Behavior rule definition

The behavior rule definition is an optional XML fragment in a campaign element template definition. A behavior rule definition defines how to detect when a customer has done something related to the trigger, target, or action. For example, if a target requires a customer to have searched for "hats" or browsed the Furniture category three times in the last week, then the target must have a behavior rule that defines how to detect those behaviors.

Each occurrence of the behavior is called an event. When the marketing services detect the event defined in the behavior rule:


When to use a behavior rule definition

A campaign element needs a behavior rule definition in its template definition only if its function requires the marketing services to detect information associated with a customer's behavior. The following are examples of campaign elements shipped with the Management Center that have a behavior rule definition: the Catalog Browsing Behavior target, the Online Behavior target, the Customer Registers trigger, Customer Participates in Social Commerce trigger, and the Display Recently Viewed action.

A campaign element does not need a behavior rule definition if its function relies on data other than a customer's behavior and that information exists elsewhere. For example, the Purchase History target does not have a behavior rule definition because a customer's purchase history data is captured in the Order Management subsystem.


Where behavior rule definitions are stored

Table: DMELETEMPLATE

Column: BEHAVIORXML


Format of behavior rule definitions

Behavior rule definitions have a number of mandatory and optional parameters. The following example shows the full list of parameters:

<BehaviorRule 
   command= "COMMAND_TO_MATCH" 
   processOnCommandExit="true/false"
   action="send/record/custom" 
   comparison="MARKETING_comparison"
   caseSensitive="true/false"
   maxSize="MARKETING_numberOfTimes"
   maxTotalSize="MARKETING_numberOfTimes"
   relativeDays="MARKETING_daysOperator"
   numberOfTimesOperator="MARKETING_numberOfTimesOperator"
   callCmdOnMatch="BEHAVIOR_RULE_TASK_COMMAND"  >   
<Variable 
      name="VARIABLE1_NAME_TO_MATCH"
      value="VARIABLE1_CONTENT_TO_MATCH"
      type="TYPE_OF_VARIABLE1"/>
</BehaviorRule>


Parameters in behavior rule definitions

Each parameter that a behavior rule definition can contain, as shown in the previous format example, is described here.

The values of the following three parameters are typically specified directly in the behavior rule XML fragment:

command

Specifies how the marketing services detect the occurrence of an event related to the campaign element. You can specify events using one of three methods:

Method Details and example
1. By specifying the name of the command from a storefront URL. Examples of URL commands are CategoryDisplay or ProductDisplay. When a storefront URL is called, the marketing services check whether the URL command name matches the behavior rule command name to see if the rule applies to the current event. For example, for a target that detects a customer viewing a category display page, the parameter would look like this:

command="CategoryDisplay"

Specify an URL command to detect events is a better option than specifying a controller command, as described in the next row. Pages are often cached in dynacache. When there is a cache hit, the controller command is not called; however, the marketing services can still detect the event by the URL being called.

A number of campaign elements shipped with WebSphere Commerce match URL commands such as CategoryDisplay or ProductDisplay. If the site uses different URL commands, then these campaign elements will not work unless you specify your custom command names in the marketing component configuration file (wc-admin-component.xml).

2. By specifying the name of a controller command. Examples of controller commands are OrderProcessCmd or UserRegistrationAddCmd. For example, for a trigger that detects when a customer registers, the parameter would look like this:

command="UserRegistrationAddCmd"

When the behavior rule specifies a controller command, and that command successfully exits, the marketing services handle the event. Some events are handled by a server controller command, and in some situations, that command might fail. Examples of this are the user registration command or the logon command. In these situations, the event must be detected only when the controller command successfully exits. If your behavior rule specifies a controller command, :

  1. Specify the value true for the processOnCommandExit parameter in the behavior rule (see the next parameter in this topic).

  2. Register the controller command in the marketing component configuration file (wc-admin-component.xml).
3. By specifying the name of a command passed to the marketing services. An example is the command SocialCommerceInteraction specified for the trigger Customer Participates in Social Commerce and the target Social Commerce Participation.

To inform the marketing services of an event that occurs outside of the WebSphere Commerce server environment, call the Process MarketingTrigger service. You can give the event any name you want. You then specify that name in the behavior rule and use the same name for the DM_ReqCmd parameter in the Process MarketingTrigger service call. For more information, see Inform the marketing services of an external event for a trigger or target.

A command value of * means that all commands should be checked for the associated name-value pairs.

The command value can be a list of commands if there are multiple commands associated with the same behavior. For example, for searches, Web 1.0 stores use the CatalogSearchResultView command whereas Web 2.0 stores use the AjaxCatalogSearchView command. Therefore, the command value for search targets is "AjaxCatalogSearchView,CatalogSearchResultView".

For examples of commands used in behavior rules, see the tables in List of shipped campaign element templates and task commands. URL commands are store-specific. For examples of URL commands used in the Madisons starter store, see the relevant store page topic within the section Site flow and interactions in the Madisons starter store. For example, for the Shop Cart page, the services listed under "Links and buttons" use the same names as the associated URL commands (AjaxOrderChangeServiceItemDelete, AjaxPromotionCodeManage, and so on).

processOnCommandExit

(Optional) Specifies whether the event occurs when a controller command exits. Values are true or false; the value relates to the previous command parameter:

  • If the command parameter is a page URL command, then this value is false.

  • If the command parameter is a controller command that must successfully exit, then this value is true.

action

(Required) Specifies what to do when the marketing services detect the event specified in the behavior rule. Valid values are:

  • send: Forward the occurrence of this event to the marketing services to be processed. This value applies to triggers.

  • record: Forward the occurrence of this event to the marketing services so that the behavior is recorded for a customer. This value applies to targets and actions.

  • custom: Detect the occurrence of this event, but do not forward the event to the marketing services. When action=custom, a custom task command handles the processing of this event. Some customization scenarios might use this value to detect events but then record the data using some other means.

  • (empty): Do not record the occurrence of this event, and do not forward the event to the marketing services. Leave the action parameter empty to simply evaluate if the current request matched the behavior defined in the behavior rule. For example, the Current Page target shipped with Management Center leaves the action parameter empty; this target checks to see if the event has occurred (a customer has viewed a specific store page), but the event is not recorded.

The following parameters are optional, depending on the function of the campaign element. In many cases, the parameter values are references to user interface properties that business users will specify when they set up a campaign element in the Marketing tool (in the examples, look for the values that start with MARKETING_). These data are stored as name-value pairs in the DMELEMENTNVP table.

comparison

(Optional) Defines how to compare the actual parameter values detected in the event with the values specified in the behavior rule. The comparison parameter is required only for campaign elements that:

For example, a target that detects a matching keyword search (q=television) or a matching cookie parameter (ZIPCODE=90210) must use the comparison parameter.

Typically, campaign elements that match parameters allow business users to specify the comparison option in the user interface. In these cases, the value of the comparison parameter references the name-value pair in the DMELEMENTNVP table, as shown in this example:

comparison="MARKETING_comparison"

To specify the comparison value directly in the behavior rule definition, valid values are:

= The specified value must be an exact match to the actual value.
end The specified value must match the end of the actual value string.
start The specified value must match the beginning of the actual value string.
contain The specified value must be contained in the actual value string.
any The specified value can match with any value in the actual name-value pair.
recordAll The specified value can match with any value in the actual name-value pair, and each individual value must be recorded in the user behavior.

If you require a different calculation to match the specified value with the actual value, then create a custom task command that implements UserBehaviorRuleTaskCmd to implement the check. The method getReturnValue can return the value from the behavior rule that matches the actual value if there is match. If the actual value does not match any of the specified values, then the getReturnValue method returns null.

caseSensitive

(Optional) Specifies if the matching of name-value pairs should be case-sensitive or not case-sensitive. Values are true and false; the default value is true.

maxSize

(Optional) For each value that can be matched in this behavior rule, this is the maximum number of times the marketing services will record a customer's behavior associated with the value. Consider a behavior rule that matches a keyword search for "hats" and "shirts." If maxSize=4, then for each customer, the marketing services will record up to 4 occurrences of searching for "hats" and up to 4 occurrences of searching for "shirts." For example, the Catalog Browsing Behavior target shipped with Management Center uses the maxSize parameter. The default value is 1.

Typically, campaign elements that use maxSize parameter allow business users to specify this number in the user interface. In these cases, the value of the maxSize parameter references the name-value pair in the DMELEMENTNVP table, as shown in this example:

maxSize="MARKETING_numberOfTimes"

maxTotalSize

(Optional) For this campaign element, this is the maximum number of times the marketing services will record a customer's behavior in total. Consider a behavior rule that matches a keyword search for "hats" and "shirts." If maxTotalSize=4, then for each customer, the marketing services will record up to 4 occurrences of searching for either "hats" or "shirts."

Typically, campaign elements that use maxTotalSize parameter allow business users to specify this number in the user interface. In these cases, the value of the maxTotalSize parameter references the name-value pair in the DMELEMENTNVP table, as shown in this example:

maxTotalSize="MARKETING_numberOfTimes"

The following table provides examples of how the maxSize parameter and the maxTotalSize parameter are used together for two campaign elements shipped with WebSphere Commerce:

Campaign element maxSize value maxTotalSize value
Recently Viewed action 1

This value means that each unique catalog entry or category that a customer views is recorded only one time so that there are no duplicates in the recently viewed list.

5

This value means that a maximum of 5 catalog entries or categories in total will be recorded and displayed in the recently viewed list.

Social Commerce Participation target 5

This value means that each type of social commerce activity–a product review, or blog entry, or photo upload–is recorded up to 5 times for a customer.

5

This value means that a customer must participate in social commerce a total of 5 times to meet the target criteria. Since the maxTotalSize value and the maxSize value are the same, the customer can do any combination of social commerce activities to reach a total of 5.

relativeDays

(Optional) Specifies how many days relative to the current date the event must occur to meet the criteria of the campaign element. For example, for a target that requires a customer to have browsed the Furniture category "10 times in the last 3 days," the relativeDays parameter value is <=. This parameter prevents the marketing services from storing unnecessary data.

  • If the relativeDays parameter has a value, then the marketing services will store only the most recent occurrences, up to the maxSize or maxTotalSize value.

  • If the relativeDays parameter does not have a value, then the marketing services will record and store only the first occurrences, up to the maxSize or maxTotalSize value.

Typically, campaign elements that use the relativeDays parameter allow business users to specify this number in the user interface. In these cases, the value of the relativeDays parameter references the name-value pair in the DMELEMENTNVP table, as shown in this example:

relativeDays="MARKETING_daysOperator"

numberOfTimesOperator

(Optional) Defines the relation between the specified maxSize or maxTotalSize value and the actual number of times the event occurred. For example, for a target that requires a customer to have browsed the Furniture category "less than 10 times," the numberOfTimesOperator parameter value is "<" (less than). If you are creating a target that is similar to the Online Behavior target shipped with Management Center, then include this parameter in the behavior rule.

Typically, campaign elements that use the numberOfTimesOperator parameter allow business users to specify the operator in the user interface. In these cases, the value of the numberOfTimesOperator parameter references the name-value pair in the DMELEMENTNVP table, as shown in this example:

numberOfTimesOperator="MARKETING_numberOfTimesOperator"

To specify the value directly in the behavior rule definition, valid values are:

= Equals.
> Greater than.
>= Greater than or equal to.
< Less than.
<= Less than or equal to.
* Any number of times.

If the value is = , then the marketing services will record up to the maxSize value plus 1 occurrences, to determine when the behavior has exceeded the number of occurrences specified in the maxSize parameter. For example, the Catalog Browsing Behavior target uses this value.

callCmdOnMatch

(Optional) Specifies a task command to call to perform custom processing of the event. The specified task command must implement BehaviorRuleTaskCmd.

Here is a custom processing example: you want to record the top browsed products in a category; however, the marketing services currently record the events against individual customers. You want to use the marketing services to detect the product browse events, but you create a custom task command to record the browse of each category in total for all the customers in the store.

Variable name value type

(0 or more) Defines the name-value pairs to match in the event. There are five types of events that a campaign element can match, as described in the following table. Typically, a business user selects either the variable name, or the value, or both, in the user interface. In these cases, the variable parameter values reference the name-value pair in the DMELEMENTNVP table. The examples shown for each event to match in the following table use this method (look for the values that start with MARKETING_).

Event to match Variable format example and explanation
Match a name-value pair, for example, on a store page URL or in a cookie. Example: The existing Current Page target has the following variable defined in its behavior rule to match the product display page that a customer is currently viewing:

<Variable name="productId" value="MARKETING_catalogEntryIdList" type="NVP"/>

Where:

  • name: (Required) The name of the name-value pair to match.

  • value: (Required) The value of the name-value pair to match. The value * means any value will match.

  • type: (Required) NVP

Match a referring external site. Example: The existing External Site Referral target has the following variable defined in its behavior rule to match the referring site:

<Variable name="MARKETING_referralURLValue" value="MARKETING_equalsOrEndsWith" type="REFERRAL"/>

Where:

  • name: (Required) The domain of the external site.

  • value: (Required) The operator that describes how to match the actual referral URL to the specified referral URL value. Valid values are:

    • =: The actual referral URL must match exactly the specified referral URL.

    • end: The actual referral URL must match the end of the specified value string for the referral URL.

    • *: Any referral URL will match.

  • type : (Required) REFERRAL

Match a name-value pair on an external site referring URL. Example: The existing External Site Referral target has the following variable defined in its behavior rule to match a name-value pair on the URL of the referring site:

<Variable name="MARKETING_urlName" value="MARKETING_urlValueList" type="REFERRALNVP"/>

Where:

  • name: (Required) The name of the name-value pair to match in the referral URL.

  • value: (Required) The value of the name-value pair to match in the referral URL. The value * means any value will match.

  • type : (Required) REFERRALNVP

Match the parent category of a category or product parameter on a page URL Example: The existing Catalog Browsing Behavior target has the following variable defined in its behavior rule to match the specified parent category when a customer has browsed a specific category display page:

<Variable name="categoryId" value="MARKETING_categoryIdList" type="PARENTCATEGORY"/>

Where:

  • name: (Required) The name of the page URL parameter to match.

  • value: (Required) The value of the page URL parameter to match. The value * means any value will match.

  • type : (Required) PARENTCATEGORY

To check if the current event matches the PARENTCATEGORY rule, the marketing services work like this:

  • If the parameter productId is in the trigger parameters, then check whether the product belongs to any of the categories specified in the behavior rule.

    Otherwise:

  • If the parameter categoryId is in the trigger parameters, then check whether the category belongs to any of the categories specified in the behavior rule.

Match the date an event occurred Example: The existing Catalog Browsing Behavior target has the following variables defined in its behavior rule to match the date when a customer browsed a specific part of the store catalog:

<Variable name="MARKETING_beforeAfterOnDate" value="MARKETING_date1" type="CURRENTDATE"/>
<Variable name="MARKETING_beforeDate" value="MARKETING_date2" type="CURRENTDATE"/>

Where:

  • name: (Required) The operator that describes how the actual event date relates to the specified date. Valid values are:

    • = on the exact date

    • > before the date

    • >= on or before the date

    • < after the date

    • <= on or after the date

  • value: (Required) The date to match.

  • type: (Required) CURRENTDATE

A custom Variable type can be defined if there are no events that match the requirements for a custom scenario. When a custom Variable type is defined, create a custom task command that implements the UserBehaviorRuleTaskCmd interface to implement the check. The getReturnValue method returns the value from the behavior rule that matches the actual value, if there is match. If the actual value does not match any of the specified values, the getReturnValue method returns null. See UserBehaviorRuleTaskCmd for more information when implementing the command.


Examples

Here are some examples of XML fragments for behavior rule definitions:

For a target that detects when the customer has browsed a category a specific number of times (within an optional time frame):

<BehaviorRule 
   command="CategoryDisplay" 
   action="record" 
   maxSize="MARKETING_numberOfTimes" 
   relativeDays="MARKETING_daysOperator" 
   numberOfTimesOperator="MARKETING_numberOfTimesOperator">   
<Variable 
        name="categoryId" 
        value="MARKETING_categoryIdList" 
        type="NVP"/>   
<Variable 
        name="MARKETING_beforeAfterOnDate" 
        value="MARKETING_date1" 
        type="CURRENTDATE"/>   
<Variable 
        name="MARKETING_beforeDate" 
        value="MARKETING_date2" 
        type="CURRENTDATE"/>
</BehaviorRule>

For a trigger that detects when a customer has registered:

<BehaviorRule 
   command="UserRegistrationAddCmd" 
   processOnCommandExit="true"
   action="send" />

For a target that detects when the current request has a specific name-value pair and then matches it (match is not case-sensitive):

<BehaviorRule 
   command="*" 
   action="" 
   comparison="MARKETING_comparison"
   caseSensitive="false">   
<Variable 
        name="MARKETING_urlName" 
        value="MARKETING_urlValueList" 
        type="NVP"/>
</BehaviorRule>

For a target that records the last n recently viewed categories:

<BehaviorRule 
   command="CategoryDisplay" 
   action="record" 
   maxSize="1" 
   maxTotalSize="MARKETING_numberOfTimes" 
   comparison="recordAll" 
   relativeDays="yes">   
<Variable 
        name="categoryId" 
        value="*" 
        type="NVP"/>
</BehaviorRule>

For a target that detects when the customer has entered the site from a referring site (with an optional name-value pair on the referring URL):

<BehaviorRule 
   command="*" 
   action="" 
   comparison="MARKETING_comparison" 
   caseSensitive="false">
<Variable 
        name="MARKETING_referralURLValue" 
        value="MARKETING_equalsOrEndsWith" 
        type="REFERRAL"/>
<Variable 
        name="MARKETING_urlName" 
        value="MARKETING_urlValueList" 
        type="REFERRALNVP"/>
</BehaviorRule>


Related concepts

Campaign element template definitions

Implementation definition: for triggers

Implementation definition: for targets and actions

Related rule definition

How the marketing services record behavior for triggers and targets

About changing targets that detect or record user behavior


+

Search Tips   |   Advanced Search