Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Hi,
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.
Aha, thanks Paul!
Excellent, I was hoping there was a similar way to perform this. This seems very simple to implement. Have my upvote :)
Hello
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.