Querying the segment by Characteristic(Location) through code - On Premise – Configurations & Setup - On Premise – Configurations & Setup - Progress Community
 On Premise – Configurations & Setup

Querying the segment by Characteristic(Location) through code

  • Querying the segment by Characteristic(Location) through code
  • Hi Team,
            I am using sitefinity 7.0 with personalization module in my project. I have created 4 user segment and added different characteristics(Location) in the each segment. I want to Querying the segment  by Characteristic(Location) through code. Please send me some sample code. It is urgent.

     Thanks & Regards,

    Pravat Sharma


  • Hi Team,
    Please help out to solve the above issue as soon as possible.

     Thanks & Regards,
    Pravat Sharma

  • Hi team,

                    Still I am waiting your reply. Please provide me the solution for above issue.

  • Hello,

    To get all segments use:
    var segments = PersonalizationService .GetActiveSegments();

    Please find a sample below regarding how we change to default display behavior in customize module according to user segment:
    var segments = PersonalizationService .GetActiveSegments()
    // for each segment
                foreach (var segment in segments)
                    bool isSegmentMatch = true;
                    // for each criteria group
                    foreach (var criteriaGroup in segment.CriteriaGroups)
                        bool isGroupMatch = false;
                        // for each criterion (remember, criteria is in the OR conditions)
                        foreach (var criterion in criteriaGroup.Criteria)
                            if (this.IsCriteriaMatch(criterion, testContext))
                                isGroupMatch = true;
                        // if a group was a match, return the segment
                        if (!isGroupMatch)
                            isSegmentMatch = false;
                    if (isSegmentMatch)
                        return segment;

    You could also review the following forum post:


    Stefani Tacheva
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items