Adding a customer segment attribute to the customer segment export file
You can customize the customer segment export feature in Management Center to include more customer segment attributes in the exported file.
Note: To ensure the
security of customer information, follow all rules and regulations pertaining to handling, storing,
and accessing customer information.
Before you begin
If you want to test your customization in your development environment with
customer segment data from your production environment, complete the following task:
About this task
By default, business users can include the following customer segment attributes in a
customer segment export file:
- Email address (ADDRESS.EMAIL1)
- Logon ID (USERREG.LOGONID)
- Customer title (ADDRESS.PERSONTITLE)
- Customer first name (ADDRESS.FIRSTNAME)
- Customer last name (ADDRESS.LASTNAME)
If your business users require more customer information in the export file, you can customize the export feature to include information from any database table, including custom tables. The table, however, must have a matching value or relationship to the MEMBER_ID column of the ADDRESS table.
For example, you can customize the customer segment
export to include any of the following types of customer information for the list of customers in a segment:
- City (ADDRESS.CITY)
- State/Province (ADDRESS.STATE)
- Country (ADDRESS.COUNTRY)
- Phone number (ADDRESS.PHONE1)
- Gender (USERDEMO.GENDER)
- Marital status (USERDEMO.MARITALSTATUS)
Procedure
Customize the Marketing tool to display new customer segment
attribute options for export
- Open WebSphere Commerce Developer. Switch to the Enterprise Explorer view.
-
Define the Marketing tool text properties for the customer segment attribute options.
-
Register the new properties in the resource bundle.
-
Register the resource bundle file wherever it is used.
For example:
<dependency localName="extMarketingManagementResourceBundle" moduleName="cmc/MyCompany/extMarketingManagementResourceBundle"/>
-
Create the customer segment export object definition to include the definition for the new
customer segment attribute options. The object definition adds support for the customer segment
attribute to be used in a customer segment export object within the Management Center
framework.
-
Create the customer segment export properties view definition for the new customer segment
attribute options. The definition indicates how to render the option for users to include the new
customer segment attribute in the export file.
For example, a check box to indicate that the attribute information is included in the export file.
Extend the CustomerSegmentExtractCmdImpl
command class to customize the customer segment export feature to include the new customer segment
attributes.
-
Create an implementation Java class to handle the new attribute options.
For instance, you can name this custom class com.mycompany.marketing.segment.CustomizedCustomerSegmentExtractCmdImpl, where mycompany is the name of your company.
You must use this custom implementation class to extend the default CustomerSegmentExtractCmdImpl implementation class for the CustomerSegmentExtractCmd command class.
In your new class, extend the com.ibm.commerce.marketing.segment.commands.CustomerSegmentExtractCmdImpl command class. To extend this class, add code in your new file to call setter methods to retrieve the customer segment attributes to add to the export file. You can use the following setter methods to help you construct your class:setInclude1stAdditionalADDRESScolumns(String)
- This method adds columns for information from the ADDRESS table. You can include multiple
columns by using the format:
setInclude1stAdditionalADDRESScolumns("Column1, Column2, Column3");
setInclude2ndAdditionalUSERDEMOcolumns(String)
- This method adds columns for information from the USERDEMO table. You can include multiple
columns by using the format:
setInclude2ndAdditionalUSERDEMOcolumns("Column1, Column2, Column3");
setIncludeLastAdditionalCustomTableColumns(String, String, String)
- This method adds columns for information from custom tables. When you set this method, identify
the table, columns, and the matching value or relationship from the custom table to the
ADDRESS.MEMBER_ID column. Use the following format to define this method:
setIncludeLastAdditionalCustomTableColumns("Table", "column1, column2", "relationship to ADDRESS.MEMBER_ID")
For example, the following code calls these setter methods to retrieve customer information from the ADDRESS, USERDEMO, and USERS tables. The relationship between the USERS table and the ADDRESS.MEMBER_ID column is through the USERS.USERS_ID column.public class CustomizedCustomerSegmentExtractCmdImpl extends CustomerSegmentExtractCmdImpl implements CustomerSegmentExtractCmd{ ... public void performExecute() throws ECException { .. setInclude1stAdditionalADDRESScolumns("CITY, STATE, COUNTRY"); setInclude2ndAdditionalUSERDEMOcolumns("GENDER,AGE"); setIncludeLastAdditionalCustomTableColumns("USERS","PROFILETYPE, LANGUAGE_ID", "USERS_ID"); super.performExecute(); ... } ... }
Note: If your customization is more complex, you can use the following setter methods to override the default SQL that the export feature uses to retrieve customer information. By overriding the default SQL, you can define and use custom SQL for to retrieve customer information. When you use the following setter methods to define custom SQL, the preceding setter methods that customize the default SQL are ignored since that SQL is no longer used. When you are creating your custom implementation class, call the following setter methods to use your custom SQL. These setter methods are defined in the CustomerSegmentExtractCmd command class.setSQLSelect(String)
- This method overrides the SQL select statement that the customer segment export feature uses to
retrieve information. Define the value of the SQL statement in the following
format:
Where"SELECT TABLE_<n>.COLUMN_1, ...CLOUMN_N FROM TABLE_1, TABLE_2, ...TABLE_N WHERE TABLE_<m>.MEMBER_ID IN (<QUERY>)"
(<Query>)
is the list of MEMBER.MEMBER_ID values for the registered customers in the customer segment. The customer segment export feature uses the com.ibm.commerce.membergroup.commands.ListUsersInStoreMemberGroupCmd command to generate the list of member ID values for the customer segment that a user selects in the Marketing tool. You cannot customize the retrieval of this list for the customer segment export feature. setSQLOrderBy(String)
- This method overrides the
ORDER BY SQL
statement that defines how customer information is sorted. Define the value of the SQL statement with the following format:"ORDER BY TABLE_<x>.COLUMN_<y> ASC"
setFileHeader(String)
- This method overrides the file header of the export file. Whenever you use the
setSQLSelect(String)
setter method, you must use thesetFileHeader(String)
setter method to change the sequence of the column headings to match the sort order for your SQL. Your file header can resemble the format:"EMAIL,LOGONID,GENDER,AGE,CITY"
SELECT T1.C1, T2.C2, T3.C3 FROM T1, T2, T3 WHERE T1.C2=T2.C3 AND T1.C3=T3.C4 AND T1.MEMBER_ID IN (<Query>) ORDER BY T1.MEMBER_ID ASC
As an example, the following SQL statement overrides the default SQL to retrieve information for the customer email address, title, first name, last name, and logon ID
Your CustomizedCustomerSegmentExtractCmdImpl.java file can include the following code to override the SQL that the export feature uses to retrieve customer information:SELECT LOWER(T1.EMAIL1) AS LOWER_EMAIL1, T1.PERSONTITLE, T1.FIRSTNAME, T1.LASTNAME, T2.LOGONID FROM ADDRESS T1, USERREG T2 WHERE T1.MEMBER_ID=T2.USERS_ID AND T1.STATUS='P' AND T1.SELFADDRESS=1 AND T1.MEMBER_ID IN (<QUERY>) ORDER BY LOWER_EMAIL1 ASC
//Customize SQL query to overrides the SQL select statement //that the customer segment export feature uses to retrieve information. String customOrderby = "ORDER BY LOWER_EMAIL1 DESC"; String customHeader = "EMAIL, PHONE1, ADDRESS1 "; StringBuilder sb = new StringBuilder("SELECT "); sb.append( "LOWER(T1.EMAIL1) AS LOWER_EMAIL1, T1.PHONE1, T1.ADDRESS1, T3.PASSWORDCREATION FROM ADDRESS T1, USERDEMO T2, USERREG T3 ") .append("WHERE T1.MEMBER_ID=T2.USERS_ID") .append(" AND T1.MEMBER_ID=T3.USERS_ID ") .append("AND T1.MEMBER_ID ").append("IN ").append("(<QUERY>)"); String customSQL = sb.toString(); setSQLSelect(customSQL); //Override the ORDER BY SQL statement that defines how customer information is sorted setSQLOrderBy(customOrderby); //Override the file header of the export file. setFileHeader(customHeader);
-
Update the customer segment export commands to include the new customer segment
attributes.
- Republish the application to pick up the LOBTools changes.
- Start or restart the WebSphere Commerce Test Server for the changes to take effect. Right-click your server and select either Start or Restart.
-
Verify that the customer segment attributes can be included when a customer segment is exported
with the Marketing tool.