Creating Live Monitor extensions

The Live Monitor extension is a custom tracker that you can modify. Create the Live Monitor extension to track specific content types or show additional information about your site visitor. 

When you create the Live Monitor extension, you should make a tracker that extends the ModuleTrackerBase (unless you want to make it entirely yourself). Live Monitor uses trackers to generate the tracking URL and process data received by the tracker handler. Live Monitor trackers must implement the EPiServer.LiveMonitor.Services.ITracker interface. In the Live Monitor main package, the ModuleTrackerBase class implements the EPiServer.LiveMonitor.Services.ITracker interface and provides validation before performing further actions. 

Custom module tracker that implements the ITracker interface

The ITracker interface defines two methods:

  • string BuildTrackingUrl(string trackingUrl, ContentData contentData)

    You manipulate the tracking URL by adding query strings that serve information necessary for processing in the ProcessingTrackingRequest() method. You can retrieve the query strings added here in the ProcessingTrackingRequest() method from the HttpContext object.

  • void ProcessTrackingRequest(ref MonitoringData monitoringData, HttpContextBase context)

    You can retrieve information from the HttpContextBase object, or you can set other services to the monitoring data object to provide information about the current hit (such as the action of opening a page). The Live Monitor Visitor Panel displays the information as visitor information.

    Set the NodeId and VisitorId on the monitorigData object; without them, the current hit is not processed. 

    Note: To bypass any concrete content data (pages) or any types of content, do not set the necessary data fields for the monitoringData(NodeId, VisitorId).

    You can add custom information to the PropertyBag of monitoringData. See the Showing custom information about visitors section.

Module tracker which inherits the ModuleTrackerBase

ModuleTrackerBase filters content data types to be tracked by Live Monitor and filters tracking requests to be processed. Based on content types and the request validation logic provided by the module, the ModuleTrackerBase validates before building the tracking URL or processing a tracking request.

ModuleTrackerBase exposes the following abstract methods that need to be implemented by the module in the extension.

  • protected abstract ITypeFilter TypeFilter { get; }

    Specifies the content types filter for the module to be tracked. Only content types allowed by the type filter are tracked. See the Defining a TypeFilter section to create a type filter.

  • protected abstract string AddParamsToTrackingUrl(string trackingUrl, ContentData contentData);

    Adds the query string to the tracking URL and returns the modified tracking URL.

  • protected abstract bool IsValidRequest(HttpContextBase context);

    Validates a tracking request before processing in ITracker.ProcessingTrackingRequest, such as checking for the existence of a query string in the context.

  • protected abstract void AddData(ref MonitoringData monitoringData, HttpContextBase context);

    Set basic data fields for the monitoringData object. You must set at least the two required fields (NodeId, UserId) to make the monitoringData valid. You can add custom data to the PropertyBag of the monitoringData.

Defining a TypeFilter

Live Monitor uses TypeFilter to filter the types of content (nodes) displayed on the Dashboard UI.

Note: Every module needs to create a TypeFilter. If the module does not provide a TypeFilter, no nodes are visible in the UI.

The following example shows how to define a custom TypeFilter by inheriting from the LiveMonitor.Services.TypeFilter:

public class CustomTypeFilter : LiveMonitor.Services.TypeFilter
  public CommerceTypeFilter()
    : base(/*string*/typefilterName,
      new List<Type>() { /* list of allowed content types*/})

Showing custom information about visitors

To show information about visitors browsing the site along with the basic information provided by Live Monitor main package, follow these steps.

  1. Define the key for the field. For example, "itemsincart”.
    monitoringData.PropertyBag[“itemsincart”] = 3/*number of item in cart*/
  2. Create a node in the embedded language file corresponding to the key (defined in step 1) to translate the property name on the Visitor Panel to the necessary languages. The following example shows how the node should be structured:
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      <language name="English" id="en">
                <itemsincart></itemsincart>

The custom user information appears in the Visitor Panel, as shown.

Last updated: Mar 03, 2016