+1-888-365-2779
Try Now
More in this section

Forums / Deployment / Querying the segment by Characteristic(Location) through code

Querying the segment by Characteristic(Location) through code

4 posts, 0 answered
  1. Pravat
    Pravat avatar
    59 posts
    Registered:
    22 Jun 2010
    18 Apr 2014
    Link to this post

    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

     

  2. Pravat
    Pravat avatar
    59 posts
    Registered:
    22 Jun 2010
    21 Apr 2014 in reply to Pravat
    Link to this post

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

     Thanks & Regards,
    Pravat Sharma


  3. Pravat
    Pravat avatar
    59 posts
    Registered:
    22 Jun 2010
    22 Apr 2014 in reply to Pravat
    Link to this post

    Hi team,

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

  4. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    22 Apr 2014
    Link to this post
    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;
                                break;
                            }
                        }
      
                        // if a group was a match, return the segment
                        if (!isGroupMatch)
                        {
                            isSegmentMatch = false;
                            break;
                        }
                    }
      
                    if (isSegmentMatch)
                        return segment;
                }

    You could also review the following forum post:

    www.sitefinity.com/developer-network/forums/general-discussions-/sitefinity-api-documentation-personalization-in-content-level

    Regards,
    Stefani Tacheva
    Telerik
     
    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
     
4 posts, 0 answered