Aggregation
(For analytics endpoints only)
Aggregation is a process of combining one or more data attributes with aggregation operators. The output of an aggregation function is aggregated numerical values that can be used to create a statistical chart. Each individual aggregation contains two keys: attribute and operator in the list of dictionaries.
Aggregations are valid for all User Data categories, Session Data categories, and Event Data categories having attribute data type (Count, Integer, and bool only)
aggregation=[{"attribute":"Attribute Name","operator":"Operator Name"}]
Here are the valid aggregation functions:
Aggregation Functions | Aggregation Operator Name | Valid Attribute Data Type |
Summation | sum | Integer, Bool |
Average | avg | Integer, Bool |
Minimum | min | Integer, Bool |
Maximum | max | Integer, Bool |
Note: For JSON (user_custom_property and event_custom_property) attribute data type, this supports aggregation functions like(sum/avg/min/max) as well if property_name values contain integer values. If aggregation functions are used with string value then this will return an empty response [Example]
Sample for JSON type aggregation:
aggregation=[{"attribute":"user_custom_property","property_name":"price","operator":"avg"}]
aggregation=[{"attribute":"event_custom_property","property_name":"duration","operator":"avg"}]
Example: [Link]