Create segment characteristics
Once you create a segment, you define one or more characteristics that contain the conditions, upon which Sitefinity CMS serves personalized content to the segment. Such conditions may be IP address, Location, Landing URL, and so on. Sitefinity API supports programmatic creation of the following characteristics by:
- User role
- IP address
- Location
- Landing URL
- Query string
- Referral URL
- Visited page URL
- Time of day
- Visit duration
Segment characteristics are represented programmatically as objects of type Criterion
(Telerik.Sitefinity.Personalization.Impl.Model.Criterion
). To create a Criterion
, you need to instantiate a new object of type Criterion
and set its properties:

The following samples give more details how to use the properties, listed above:
Create criterion by user role:
To create a criterion by user role you pass the role Id
and Name
and set the CriterionValue
in the proper format:
Create criterion by IP Address
Creating a criterion by IP address is as simple as passing the IP address as string and setting the address to the CriterionValue
property in the proper format:
Create criterion by Landing URL or Querystring:
Creating criteria by Landing URL or Querystring introduce an added functionality of using a criterion operator. Since these criteria allow you to specify a desired value and a second value to compare to, you also need to choose which operator to use for the comparison of the two. Thus, you can set conditions, such as “this characteristic is valid for visitors that land on an URL that contains/equals/starts with etc. the following value” The supported criterion operators are:
- "=" - equal to
- "!" - not equal to
- "contains" - contains
- "!contains" - does not contain
- "startswith" - starts with
- "!startswith" - doesn't start with
- "endswith" - ends with
- "!endswith" - does not end with
The following example demonstrates how to create a Landing URL and use the criterion operators, listed above:
The similar logic applies when creating a criterion by QueryString:
Create criterion by Location:
Create criterion by Time of day:
To create a Time of day criterion, you need to pass two different DateTime
values when building the CriterionValue – one for the start time and one for end time of the specified timeframe of the visit. For example, the criterion applies to visitors that browse the website between 9am and 5pm:
Create criterion by page visit duration
Similar to the Time of day criterion, when working with Page visit duration criterion, you need to pass two values to specify min and max duration. You also specify the time unit.
NOTE: Supported values for time unit are “seconds” or “minutes”.
Create criterion by visited page URL