Custom queries, segmentation, and aggregation of session data