Now that you created a segment, you can take things to the next level and use a Custom Field to define segment criteria.
Creating a Custom Field
First, create a custom field to use for the Segment:
-
In the Control Panel go to Configuration → Custom Fields.
-
Click on User.
-
Click the Add button () button in the top right.
-
On the next page, click on Dropdown.
-
For the Field Name enter Cardholder Type.
-
For values, enter None, Basic, Gold, and Platinum on four separate lines.
-
Click Save.
Now any time user is created, they are prompted to enter the Cardholder Type, and existing users can select it from their user profiles.
For more information on adding Custom Fields, see Adding Custom Fields.
Defining a Segment with a Custom Field
Next, use a custom field to define another segment.
-
From Segments Administration, click the Add button ().
-
Click in the text area at the top of the page, enter the name Premium Card Prospects.
-
For User Properties select Cardholder Type.
-
Click on the operator field and set it to equals.
-
Select Basic from the select box.
- Click Save to save your Segment.
As you can see, segment criteria can be easily defined using Liferay DXP’s built-in criteria or your own custom fields. Now, you’ll use session data to make this Segment definition even more robust.
Extending a Segment With Session Data
So far, you’ve used criteria derived from user profiles to determine if they should be members of a segment; now it’s time to use session data to make your criteria more effective.
-
Click the Actions button () next to the Premium Card Prospects segment and select Edit.
-
Click the Session dropdown from the Properties menu.
-
Set the comparator for Session Properties to Or.
-
Drag Cookies into the Session Properties section.
-
Change the selection box to contains.
-
Enter Cards in the Key text box.
Now any user who has a cookie from visiting the Cards page is evaluated as part of the Premium Card Prospects segment.