VisitorGroups

One way you can personalize a digital experience in Optimizely is to create a visitor group with criteria for that group. For example, you can design a product banner specifically for first-time visitors, or for visitors from a geographic region or market.

If you have multiple visitor groups, a visitor may match more than one visitor group. You then can use personalization groups to group content to avoid displaying the same content twice, and display fallback content to visitors who match no visitor groups.

The Problem

Having a few VisitorGroups is not a problem, pretty manageable if you ask me. However, when the list of VisitorGroups grows, grows and grows some more, you end up with something like this:

Most of the times this issues arises because the customer is hosting multiple websites and there’s no real way of filtering the VisitorGroups since it’s a one big flat list

The Solution

With CMS12 since everything is in dotnet the system also utilizes standard dotnet dependency injection, meaning we can swap out “system” services with our own 😉

This involves the following steps

  • Implement a IVisitorGroupRepository
  • Override the List() and Save()
  • Intercept Calls to existing VisitorGroups

Code

Startup.cs

Make sure to call the helper method in your Startup.cs to have the calls intercepted and make the system invoke your own IVisitorGroupRepository instead of the default one

services.AddFilteredVisitorGroups();

Conclusion

Although this is a nice way of “hacking” the system, instead of adding the “hostname” to uniquely identify the VisitorGroups, a better approach would be to create a custom criteria and tag the visitor group with it to have “Global” and “Local” VisitorGroups giving you much finer control of the system. Something for Part 2 of this post then 😅