Back

Rolling Average is the arithmetic mean of numerical values in a Number or a Tally that are all captured as entries in a Timeline. The Timeline's expiration determines which entries can be factored into the final average.

In this article:

Table of Contents Placeholder

Rolling Average With Timeline Expiration

The rolling average includes all time-sensitive entries—excluding expired entries—that are in the Timeline. As the timeline progresses, expired entries are discarded and the final rolling average is recalculated with the next set of valid entries.

This facet is best understood with the help of a 90-day timeline of order total values. As illustrated in the table below, the order total entry on Jan 1 is included in the arithmetic mean provided it exists in the 90-day timeline.

90-day Timeline
Timestamp Entries Order Total (in $)
Jan 1 10.00
Feb 15 20.00
Mar 25 30.00
Rolling Average is (10.00 + 20.00 + 30.00) ÷ 3 = 20.00

The same entry is discarded after 90 days and the rolling average is recalculated for the existing entries. Notice how the resulting average changes when an expired entry is excluded from the aggregate.

90-day Timeline
Timestamp Entries Order Total (in $)
Feb 15 20.00
Mar 25 30.00
Apr 10 40.00
Rolling sum is (20.00 + 30.00 + 40.00) ÷ 3= 30.00


Rolling Average Without Timeline Expiration

All entries count towards the rolling average; none of the entries are excluded. The enrichment keeps the average rolling to account for incoming new entries. The 90-day timeline we discussed above would now look something like this:

90-day Timeline
Timestamp Entries Order Total (in $)
Jan 1 10.00
Feb 15 20.00
Mar 25 30.00
Apr 10 40.00
May 15 50.00
Rolling Sum is (10.00+20.00+30.00+40.00+50.00)÷5 = 30.00

 

 

Adding and Configuring the Enrichment

  1. Add a Number attribute or a Tally attribute. This attribute will store the resulting average.
  2. Click Create Enrichment and select Set Rolling Average Based on Timeline.
  3. From the first drop-down, select the Number/Tally attribute that has the values you want to average out.
  4. From the next dropd-own, select the timeline where the number/tally is being recorded.
    rolling-average-enrichment.png
  5. Click Finish to confirm, then Save/Publish your profile.

Usage Example

In this example, you will learn how to record a timeline of purchase events that have occurred in the last 90 days and, at the same time, capture the resulting order total values. Then you will create a new number attribute along with the rolling average enrichment to average out the order totals.

STEP 1: Add a new Number Attribute.
Purpose: To store the order total values from the receipt page.

Title: Order Total
Scope: Current Visit
Enrichment: Set this Metric to "order_total"
WHEN: ANY_PAGE_EVENT
Attach or Create Rule: Current URL contains "receipt.html"

order_total_metric.png

STEP 2: Add a new Timeline Attribute and set each entry to expiry after 90 days.
Purpose: To record every order confirmation event on the receipt page and capture the numerical order total values.

Title: 90-day Order Timeline
Scope: Visitor
Entry: Update Timeline
Capture Attribute Data: Order Total
WHEN: ANY_PAGE_EVENT
Attach or Create Rule Condition: Current URL contains "receipt.html"
Entry: Set Expiration of Timeline events
Set each event in this Timeline to expire after "90" days

90_day_timeline_entries.png

STEP 3: Add a new number and create the 'Set Rolling Average Based on Timeline' Enrichment.
Purpose: To crunch numbers and store the resulting average.

Title: 90-day Order Average
Scope: Visitor
Enrichment: Set Rolling Average based on Timeline
Set this Metric to the Rolling Average of Metric "Order Total" captured in timeline "90-day Order Timeline"

average_90_days.png

Results

Go to API sampler in your profile and submit a query to find out how many entries were logged into the Timeline and also to determine the final average.

TIP: Locate the title you assigned to the Metric/Tally and the Timeline Attribute.

Assuming there are two entries in the 90-day Order Timeline, the API Sampler will display the results like so:

API_Sampler_-_Timeline.png

Similarly, here's the final average stored in the 90-day Order Average Metric:

API_Sampler_-_Metric_Average.png