Defensive Metrics for Adobe Analytics

Background

As an Adobe Analytics implementation becomes more useful, the data it produces comes under greater scrutiny. It is useful to have some metrics in place that can highlight and help explain “anomalous” scenarios, such as a non-Page View hit (a “Page Event” in Adobe-speak) being recorded before the Page View hit can be recorded for the current page.

Scenarios

The following metrics will be defined and their implementation will be described:

  • First hit of Visit (Page View OR Page Event)
  • First Page View of a Visit
  • First Page Event of a Visit
  • Page Event hit BEFORE Page View hit
    • That is, a Page Event that occurs with no record of a Page View hit for the current page load

First hit of Visit

This is straightforward to define:

  1. Assign a Success Event in the Adobe Analytics Admin Console
    • Name = “First hit of Visit (any hit type)”
    • Ensure that “Recording” is set to “Once per Visit”
  2. Configure a Processing Rule to set the assigned Success Event on every hit

It is now simple to isolate the first hit of every Visit (or “Session”) by creating a Segment where “First hit of Visit (any hit type)” exists.

First Page View hit of Visit

Also straightforward to define:

  1. Assign a Success Event in the Adobe Analytics Admin Console
    • Name = “First Page View hit of Visit”
    • Ensure that “Recording” is set to “Once per Visit”
  2. Configure a Processing Rule to set the assigned Success Event on every hit where Page Name is set or PageURL is set
    • NOTE: even if Page Name is set when a hit reaches the Adobe processing servers, if the hit is determined to be a Page Event hit, the Processing Rules interface does not acknowledge that the Page Name variable is set; the same goes for the PageURL variable

It is now simple to isolate the first Page View hit of every Visit by creating a Segment where “First Page View hit of Visit” exists.

First Page Event hit of Visit

As you may have guessed, this is straightforward to define:

  1. Assign a Success Event in the Adobe Analytics Admin Console
    • Name = “First Page Event hit of Visit”
    • Ensure that “Recording” is set to “Once per Visit”
  2. Configure a Processing Rule to set the assigned Success Event on every hit where neither of Page Name or PageURL is set

It is now simple to isolate the first Page Event hit of every Visit by creating a Segment where “First Page Event hit of Visit” exists.

Processing Rule Configuration

The Processing Rule that will set the metrics described above is easier to show than describe. It relies on a couple of capabilities that are specific to the Adobe Analytics Processing Rule interface:

Define a Processing Rule that sets Success Metrics that have been configured to record "Once per Visit" in the Adobe Analytics Admin Console
Processing Rule that sets Success Events that help identify the various types of “first hit” for each Visit

Page Event hit before Page View hit

Unless you have a specific reason for wanting this to happen, seeing a Page Event hit that occurs after page load but before a Page View hit has happened can signal something that should be investigated.

While the other metrics described in this post can be created as Calculated Metrics using the “Hit Depth” variable (mainly for use in the Adobe Analytics Workspace interface), there is no comprehensive method for replicating this one other than to record it in real time (i.e. as it happens).

There are three requirements to make this work:

  1. Define a callback using s.registerPostTrackCallback that sets a flag in the correct circumstances
  2. Ensure that the flag is included on all s.tl() hits
  3. Configure a Processing Rule to set an event when the flag is NOT set on s.tl() (Page Event) hits

The Callback

The Adobe Analytics library includes two call hooks, s.registerPreTrackCallback and s.registerPostTrackCallback, that are invoked immediately before and after, respectively, an Adobe Analytics hit.

Define a rule in Adobe LAUNCH with the following configuration (see the screenshot below as well):

  1. Name: Post-hit Callback
  2. EVENTS: [Core] Library Loaded (Page Top)
  3. CONDITIONS: (none)
  4. ACTIONS: [Adobe Analytics] Set Variables
    • Do not configure any variables
    • Open the “Custom Code” editor
    • Use the following code snippet:
//  set up some neat logging
var log = _satellite.logger;
var log_name = "Register Post Track Callback - ";
try {
  s.registerPostTrackCallback(
    function(requestUrl, s) {
      //  If the request being inspected is NOT a Page Event hit (i.e. 'pe' is NOT set),
      //  or the request is recording the 'page_view_detected' flag, set up the 'page_view_detected' flag
      //  for the next hit in the life of this page
      if (!requestUrl.match(/&pe=/) || !requestUrl.match(/page_view_detected/)) {
        //  set the flag
        s.contextData['page_view_detected'] = true;
      }
    }, s);
} catch (err) {
  log.error(log_name, err);
}
Main configuration elements of a Rule in Adobe LAUNCH that will register the callback on Library Loaded (i.e. as early as possible in the Adobe LAUNCH running order)
Create a Rule in Adobe LAUNCH to register the callback

In brief, after every single successful Adobe Analytics call (Page View or Page Event), this code will inspect the URL that makes up the call and determine whether or not it was a Page View. If a Page View is detected, the code is set up to make sure this is recorded on every hit until the page is reloaded or navigated away from.

Configure s.linkTrackVars

Since all set variables are included with Page Event hits on an exception basis, it is necessary to ensure that the new Context Data Variable (as set by the Rule in LAUNCH) will be included in s.linkTrackVars for every Page Event hit.

The simplest way to do this is in the doPlugins function:

  1. Ensure the appendList plug-in is included
  2. Include the following snippet inside doPlugins:
if (s.linkType) {
    s.linkTrackVars = (s.linkTrackVars == "None" ? "contextData.page_view_detected" : s.apl(s.linkTrackVars, "contextData.page_view_detected", ",", 2));
} else {
    s.linkTrackVars = "None";
}

Processing Rule Definition

Define a Processing Rule that inspects Page Event hits and sets a Success Event if the Context Data Variable page_view_detected is not set as expected (i.e. based on the code in the Adobe LAUNCH Rule defined above).

Set a Success Event if a Page Event hit is detected that DOES NOT have any record of a preceding Page View hit
Processing Rule definition that uses the Context Data Variable page_view_detected in its conditional logic

Using the Metrics

These metrics will primarily be useful when investigating unusual traffic by isolating the first hit of a Visit or checking for Page Events that occur before a Page View (for example, there may be a case in which the Page View hit never fires for a given page – this would be highlighted if that page includes at least one interaction that triggers a Page Event).

However, the first thing to do once they are set up is to use the built-in Anomaly Detection-based Alerts. An example is below:

Using the Adobe Analytics Alert capability to monitor for anomalous counts of Visits that don’t start with a Page View

Final Thoughts

There are other ways to implement most of what is described here. Some of those other ways may be simpler.

For example, instead of setting the page_view_detected flag as a Context Data Variable and then using a Processing Rule to set the Success Event, it is easier to set the Success Event directly on the Page Event hits where a preceding Page View is not detected.

However, the page_view_detected flag has other potential uses (such as detecting AJAX-style Page View hits) that make it worthwhile setting up in a comprehensive manner.

Summary

In this article, we’ve explored some metrics that can help you take control of your Adobe Analytics implementation.

Various features of the Adobe Analytics Admin Console were used (Processing Rules, Success Events configuration), along with Adobe LAUNCH and some relatively advanced capabilities of the Adobe Analytics AppMeasurement library (the doPlugins function and s.registerPostTrackCallback).

While these metrics don’t provide much value to the Digital Analyst, they can go a long way to increasing trust in the data by enabling the the Digital Analytics Developer to confidently answer questions about data quality.

Leave a Reply

Your email address will not be published.