November Happy Hour will be moved to Thursday December 5th.

smithsson68@gmail.com
Aug 22, 2011
  8335
(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 SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog