Back

Overview

A Rolling Sum is the aggregate of numerical values in a Number or Tally Attribute that are captured as entries in a Timeline. The Timeline's expiration determines which entries can be factored in during the aggregation.

Example with Timeline

This example uses a "Lifetime Orders" Timeline that captures Order Total values. All entries in the Timeline count towards the Rolling Sum, essentially making it a simple Sum. The Enrichment keeps the Sum updated to account for new Timeline entries:

Timeline Attribute: "Lifetime Orders"
Entries Order Total ($)
Jan 1 10.00
Feb 15 20.00
Mar 25 30.00
Apr 10 40.00
May 15 50.00
(Rolling) Sum is (10 + 20 + 30 + 40 + 50) = 150.00

Example with Timeline Expiration

This example uses a "90-day Orders" Timeline, which uses a 90 day expiration, so only entries captured in the last 90 days will be considered for the Enrichment. As the Timeline progresses, entries falling outside the expiration window are discarded and the final Rolling Sum is recalculated with the set of valid entries.

The table below illustrates a timeline of entries (assume today is March 25). All entries, including the entry on Jan 1, are included in the Sum.

Timeline Attribute: "90-day Orders"
Valid Entries Order Total ($)
Jan 1 10.00
Feb 15 20.00
Mar 25 30.00
Rolling Sum is (10.00 + 20.00 + 30.00) = 60.00

A few weeks later, the Jan 1 entry is discarded because it falls outside the 90 day expiration and the Rolling Sum is recalculated for the valid entries. Notice how the resulting average changes when an expired entry is excluded from the aggregate.

Timeline Attribute: "90-day Orders"
Expired Entries Order Total ($)
Jan 1 10.00
Valid Entries Order Total ($)
Feb 15 20.00
Mar 25 30.00
Apr 10 40.00
Rolling sum is (20.00 + 30.00 + 40.00) = 90.00 


Add and Configure the Enrichment

1. Add a new Numner Attribute or a Tally Attribute. This Attribute will store the results of the sum.

2. Give it a Title and set its Scope.

3. Click on 'Create Enrichment' and select 'Rolling Sum Based on Timeline'.

rolling_sum_enrichments.png

4. From the first dropdown, select the Number or Tally that contains the numerical values you want to sum up.

5. From the next dropdown, select the Timeline where the Number or Tally is being recorded.

6. Click Finish to confirm. Then Save/Publish the changes in your profile.

Usage Example

In this example, you will learn how to record a Timeline of order confirmation events on the receipt page for the last 90 days and, at the same time, capture the resulting order total values. Then you will create a new Number along with the Rolling Sum Enrichment to aggregate all the order total values recorded into the Timeline.

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 Number 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 Sum Based on Timeline Enrichment.
Purpose: To crunch numbers and store the final rolling sum.

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

rolling_sum_90_day.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 to determine the final rolling sum.

Look for the Title you assigned to the Number/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 sum stored in the 90-day Order Total Number:

API_Sampler_-_Metric.png