Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

smithsson68@gmail.com
Aug 22, 2011
  8444
(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)
{
   EPiServerVisitorGroupTracker.
    VisitorGroupEvents.
     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 http://episervervgtracker.codeplex.com

Happy tracking!

Aug 22, 2011

Comments

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 CMS Developer Tools for macOS

Running Optimizely CMS on macOS presents unique challenges, as the platform was traditionally primarily designed for Windows environments. However,...

Tomek Juranek | Mar 15, 2025

Removing a Segment from the URL in Optimizely CMS 12 using Partial Routing

Problem Statement In Optimizely CMS 12, dynamically generated pages inherit URL segments from their container pages. However, in certain cases, som...

Adnan Zameer | Mar 14, 2025 |

Optimizely Configured Commerce and Spire CMS - Figuring out Handlers

I recently entered the world of Optimizely Configured Commerce and Spire CMS. Intriguing, interesting and challenging at the same time, especially...

Ritu Madan | Mar 12, 2025

Another console app for calling the Optimizely CMS REST API

Introducing a Spectre.Console.Cli app for exploring an Optimizely SaaS CMS instance and to source code control definitions.

Johan Kronberg | Mar 11, 2025 |