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
Display Child Pages in Content Delivery API Response

The below example will implement an instance of IContentConverterProvider to customise the serialisation of PageData and output child pages in the...

Minesh Shah (Netcel) | Oct 4, 2022

Bring the Report Center back in Optimizely CMS 12

The Report Center has been a part of Optimizely CMS since its first debut in version 5R2 in 2008, but in CMS 12, it's removed! Don't despair! Make...

Tomas Hensrud Gulla | Oct 4, 2022 | Syndicated blog

Customizing Property Lists in Optimizely CMS

Generic property lists is a cool editorial feature that has gained a lot of popularity - in spite of still being unsupported (officially). But if y...

Allan Thraen | Oct 2, 2022 | Syndicated blog

Optimizely names Luminary Senior Developer, Ynze Nunnink, OMVP

Luminary Senior Developer and Optimizely Lead, Ynze Nunnink has secured the coveted position of Optimizely MVP. Earning a Platinum badge for his...

Ynze | Oct 2, 2022 | Syndicated blog