SaaS CMS has officially launched! Learn more now.

Filtering Audiences



I have been digging thru the documentation but couldn't find a good reference anywhere. On a CMS 12, how do we filter the Audience criterias, either just removing some of the choices, or renaming them.
It's not filtering the created Audiences, I've found that blogpost (Customizing VisitorGroup Behavior in Optimizely CMS | Kunal Shetye's Blog), it is the criteras like for example "Ip Range" when building the Audience.

Jan 17, 2024 15:34


You should be able to use a similar technique to the one mentioned in Kunal's blog post. In this instance though you'd want to intercept IVisitorGroupCriterionRepository. If you create a class which implements that interface like this:

public class FilterVisitorGroupCriteria : IVisitorGroupCriterionRepository
    private readonly IVisitorGroupCriterionRepository _instance;
    public FilterVisitorGroupCriteria(IVisitorGroupCriterionRepository instance)
        _instance = instance;

    public IEnumerable<VisitorGroupCriterion> List()
        //Get the list of criteria from the default implementation
        var initialCriteriaList = _instance.List();
        foreach (var criterion in initialCriteriaList)
            //Add your filtering here and return the criteria you want to keep
            yield return criterion;

Then register it as an interceptor in your startup.cs like this:

services.Intercept<IVisitorGroupCriterionRepository>((a, b) => new FilterVisitorGroupCriteria(b));

You should then be able to do whatever filtering you need to to exclude the criteria you're not interested in.

Jan 18, 2024 11:24

Aha, thanks Paul!
Excellent, I was hoping there was a similar way to perform this. This seems very simple to implement. Have my upvote :)

Jan 18, 2024 12:11
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.