Aggregates and Running Aggregates

Aggregates are custom customer attributes that are calculated from already existing data. They help you calculate aggregated information for every customer. An example of aggregate would be calculating a customer's lifetime value: In your report, you would use sum>purchase>total_price.

Running aggregates are custom event attributes, which is the main difference to aggregates. They help you calculate aggregated information for any event. Running aggregates can be used in almost any analytical part of Bloomreach Engagement.

Aggregate types
minimum / maximumReturns the smallest / biggest value from the dataset.
sumSums values in the dataset. For example, sum > purchase > total_price will return the total spend.
countCount the number of data points. For example, count > purchase will return the number of purchases.
avg (average)Returns the average of all values of that specific event.
first / lastReturns the value of the first / last occurrence of that event.
existsReturns either 1 or 0. For example, if a customer never purchased before, then exists > purchase will return 0 and vice versa.
most commonReturns the most common value, such as the most viewed item.
count distinctThis counts distinct values in a data set, such as how many different categories a specific customer viewed.
distinct valuesLists all the unique values within an aggregate.

📘

For the most common aggregate type, in case there are two (or more) equal outcomes, Bloomreach Engagement picks the first one that occurred in the event history.

🚧

When using decimal numbers, make sure to denote them by . (e.g. 12.34) as otherwise, sum , avg or other mathematical aggregates will not work properly

Grasping aggregates and running aggregates and the difference between them might be a bit tricky at the beginning. That's why we created this short video that explains the topic for you. We do recommend watching it as you will be using (running) aggregates very often in Bloomreach Engagement.

How to create a (running) aggregate

It can be created in two ways:

  • Go to Data & Assets > Data manager > Definitions > New definition.
  • Aggregates/running aggregates can also be created when selecting customer attributes/events for your analysis wherever it is possible. If you wish, you can also save them for later use (so next time it appears in the list) by clicking on the save button as shown below.
1280

Aggregates can be found under theCUSTOMER while running aggregates are under EVENT

The process of creating an aggregate is simple:

a. Select the calculation operator (sum, first, last ...)

b. Select the event with which you want to calculate the aggregate. For example Count > purchase calculates the number of purchases for all customers.

c. You can specify the metric further by adding an attribute of the event. For example Sum > purchase > total_price will calculate the total revenue generated by each customer.

Running aggregates: The difference between including/excluding the event itself

Running aggregates contain one additional setting, which is deciding whether to include or exclude the event itself from the calculation. This setting is relevant when the anchor event is identical to the event from which the running aggregate is calculated. See the 2 Use Cases about calculating revenue and conversion rate by country below for a better understanding.

'Skip first' function

You can skip any number of values for the first, last and most common aggregates. For example, you can use the aggregate "first purchase timestamp > skip 1", which will give you the timestamp of the second purchase of that particular customer.

📘

For distinct aggregate, it has 100% precision if there are less than 10k unique values. If there are more values, it has around 97% precision.

Example use cases

Aggregates

Aggregates can be used for filtering and segmenting customers or in expressions. They are usually used in campaign filters. Check out these examples to see what kind of insights are available through aggregates. Notice every analysis related to a customer.

How many purchases does a customer have in total?

How many times customer visited our page in the last 30 days?

What is a customer’s total lifetime value?

What is the average customer purchase when using loyalty points for purchase?

What was the referrer of a customer’s first visit to the webpage?

How many emails has the customer received from us in the last 14 days?

What was the last product the customer viewed?

Running aggregates

What is the revenue per country?

If you don't track country as an attribute of the purchase event, then you need to retrieve it from the session_start event using a running aggregate. For every purchase in the past Bloomreach Engagement will look a the last session_start > country that preceded that purchase and will attribute that purchase to the country which is tracked there.

Note: Changing the including/excluding operator does not make a difference here. Read the next use case for further explanation.

What is the conversion rate per country?

The metric (conversion rate) is, in this case, a formula that uses two types of events – session_start and purchase – meaning that the report cannot be broken down by an attribute of one, or the other. As mentioned above, the attribute ‘country’ is tracked for event session_start, but usually not for event purchase.

The running aggregate you will need for this report looks like this:

Here, it is crucial to switch from excluding to including. We essentially have two anchor events in this case – session_start and purchase. The running aggregate will look for the country of the last session_start both before every purchase event and before every session_start event, including that very event. In other words, the including/excluding setting matters here because the running aggregate is calculated from one of the anchor events - session_start.

The report will look like this:

You may have noticed that, in this case, you have to insert the running aggregate into Rows, before inserting the Metric. Once you insert a formula that uses two types of events under Metrics, you won't be able to choose an event attribute (or running aggregate) under Rows anymore. So make sure to start with Rows in such cases.

What was the referrer for the last session_start of this event (for example: purchase)?

When was the last time a specific weblayer was viewed by any customer?

When was the last time an email was delivered to any customer?