Querying the segment by Characteristic(Location) through co

Posted by Community Admin on 05-Aug-2018 11:18

Querying the segment by Characteristic(Location) through code

All Replies

Posted by Community Admin on 18-Apr-2014 00:00

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

 

Posted by Community Admin on 21-Apr-2014 00:00

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

 Thanks & Regards,
Pravat Sharma


Posted by Community Admin on 22-Apr-2014 00:00

Hi team,

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

Posted by Community Admin on 22-Apr-2014 00:00

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
 

This thread is closed