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:
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:
Criterion
Telerik.Sitefinity.Personalization.Impl.Model.Criterion
CriterionName
IMPORTANT: Make sure you use the property names provided in the code samples in this section.
CriterionTitle
CriterionValue
CriterionDisplayValue
IsNegated
The following samples give more details how to use the properties, listed above:
To create a criterion by user role you pass the role Id and Name and set the CriterionValue in the proper format:
Id
Name
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:
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:
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:
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:
DateTime
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”.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important