Try our conversational search powered by Generative AI!
Aug 22, 2011
(2 votes)

Announcing Visitor Group Tracking and Statistics

EPiServer Visitor Groups have some basic tracking and statistics built-in which tells you how many times a Visitor Group was “visited” or tested for a match, in other words.

Many people have commented that whilst they love Visitor Groups, sooner rather than later, marketing departments or whoever is in charge of a site is going to want more information about how successful their Visitor Groups and criteria are.

Say hello to EPiServerVisitorGroupTracker

With that in mind I have developed a framework called EPiServerVisitorGroupTracker that will give programmers a large amount of information every time a Visitor Group is tested. From this information a huge array of statistics and reports can be compiled which should keep site owners busy for a while.

You hook into the information stream by adding an event handler to the framework. You should do this when the site starts, so either in the Application_Start event or in an EPiServer Initialization Module.

protected void Application_Start(Object sender, EventArgs e)
     VisitorGroupTested += VisitorGroupTested;

private void VisitorGroupTested(object sender, 
                                VisitorGroupTestedEventArgs e)
    // Record as much or as little from the 
    // VisitorGroupTestedEventArgs as needed               

That's it, you're done! How much information to store and where to store it, depends on the requirements you have of course. The EPiServer Dynamic Data Store is an ideal candidate as a store.

Now the juicy bit

What information do you have access to in your event handler? The VisitorGroupTestedEventArgs class is defined as follows:

public class VisitorGroupTestedEventArgs : EventArgs
    public VisitorGroup VisitorGroup { get; protected internal set; }
    public IPrincipal CurrentPrincipal { get; protected internal set; }
    public HttpContextBase HttpContext { get; protected internal set; }
    public bool Matched { get; protected internal set; }
    public IEnumerable<VisitorGroupCriterion> CriteriaMatched { get; set; }
    public IEnumerable<VisitorGroupCriterion> CriteriaNotMatched { get; set; }
    public IEnumerable<VisitorGroupCriterion> CriteriaNotTested { get; set; }
    public int PointsMatched { get; set; }
    public PageReference VisitedPageReference { get; set; }
    public string VisitedPageLanguage { get; set; }

As you can see, there is plenty of useful information to allow site owners to determine if their Visitor Groups are matching and if not, why not by examining the CriteriaMatched, CriteriaNotMatched and CriteriaNotTested properties. You also have access to all the same information the criteria executed had via the HttpContext and CurrentPrincipal properties.

Performance Considerations

The events will only be fired if statistics are enabled for the Visitor Group in the Visitor Group Admin user interface. Obviously, capturing this information does add extra load to the site so use it with caution.

The events are fired on a separate IIS Request Thread from the original request that triggered the Visitor Group test so responses to page visitors will not be affected by the event firing.

How does it work?

It works by inserting proxies around the VisitorGroupRole class from EPiServer and the criteria classes that EPiServer and others develop. The information presented in the VisitorGroupTestedEventArgs class is captured in these proxies. Unfortunately, I had to use reflection is two places to achieve this but I have a couple of friends on the inside at EPiServer who I can talk to about making the Visitor Group API’s more open in EPiServer vNext Winking smile

Where can I get this?

The EPiServerVisitorGroupTracker assembly is available from EPiServer’s Nuget feed and the source code is available from

Happy tracking!

Aug 22, 2011


Aug 23, 2011 04:50 PM

Marketing teams will definitely want to report on some of these metrics. Nice work Paul!

Mar 27, 2017 12:36 PM

Please login to comment.
Latest blogs
Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog