In this article:

Table of Contents Placeholder

Requirement

You want to count a common event (for example page impressions), over a time window (e.g. last 10 days).

Problem

You could just use a timeline, adding an entry each time the event occurs, and use a metric to count the entries in the timeline, but (a) this would be wasteful and (b) timeline attributes in AudienceStream are limited to 100 entries per visitor. Beyond that, they will drop out the older entries.

Solution

In a visit, maintain a visit counter for the event. At the end of the visit, store the value of this counter in the timeline. At the start of each visit, sum the counter into another metric from the timeline.

The ultimate count is then the rolling sum from timeline (which represents previous visits) plus the visit counter (which represents the current visit).

The timeline limit of 100 entries will still apply, so if the visitor were to make more than 100 visits over the timeline length, this method will not work.

Example

In this example, we will use the number of product page views in the last 5 days.

Steps

  1. Setup a visitor number attribute "Product Page View in Visit".
    This is to capture the number of product page views in the visit.
    Product Page View in Visit.png
  2. Setup a visitor timeline attribute "5D - Visit End Product Page View".
    This is to store the value of "Product Page View in Visit" at the end of each visit and the timeline events should expire after 5 days.
    5D - Visit End Product Page View.png
  3. Setup a visitor number attribute "5D - Product Page View Count Excluding Current Visit".
    This is to capture the product page view count in the last 5 days excluding the current visit.
    5D - Product Page View Count Excluding Current Visit.png
  4. Setup a visitor number attribute "5D - Product Page View Count".
    This is to capture the sum of product page view count in the last 5 days and product page view count in current visit.
    5D - Product Page View Count.png
Version history
Last update:
‎03-08-2021 01:25 PM
Updated by: