In this article:
You want to count a common event (for example page impressions), over a time window (e.g. last 10 days).
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.
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.
In this example, we will use the number of product page views in the last 5 days.