Recipes
Realistic dashboard questions, each with a working query.
Each recipe is a complete query you can adapt. Recipes combine the operations from the previous pages, so they are the quickest way to see how the pieces fit together.
Choosing an operation
- How many events? use
count() - How many per period? use
timeseries() - How many distinct? use
unique() - What are the values? use
aggregate() - Split by a field? use
groupBy()
Recipes
Signups per day
const signups = await vanta.timeseries({
filters: filter('type', 'equals', 'user.signup'),
interval: 'day',
time: timeRange('2024-01-01T00:00:00Z', '2024-01-14T23:59:59Z'),
})Returns one bucket per day with the signup count, aligned to UTC. Quiet days appear as gaps.
Unique active users this week
const activeUsers = await vanta.unique({
field: 'userId',
filters: filter('type', 'equals', 'user.active'),
time: timeRange('2024-06-24T00:00:00Z', '2024-06-30T23:59:59Z'),
})Distinct users who sent an active event in the week. A user active every day counts once.
Average order value
const averageOrderValue = await vanta.aggregate({
filters: filter('type', 'equals', 'purchase'),
aggregations: [{ name: 'aov', field: 'data.amount', operation: 'avg' }],
time: timeRange('2024-01-01T00:00:00Z', '2024-12-31T23:59:59Z'),
})Averages the amount stored on every purchase event. Swap the operation for sum to get total revenue instead.
Checkout completion by country
const byCountry = await vanta.groupBy({
groupBy: ['context.country'],
filters: filter('type', 'equals', 'checkout.completed'),
time: timeRange('2024-01-01T00:00:00Z', '2024-12-31T23:59:59Z'),
})Groups completed checkouts by country, with the count for each. Add a second field such as data.plan for a finer breakdown.
Top plans by usage
const byPlan = await vanta.groupBy({
groupBy: ['data.plan'],
filters: filter('type', 'equals', 'purchase'),
time: timeRange('2024-01-01T00:00:00Z', '2024-12-31T23:59:59Z'),
})One group per plan with the number of purchases. Add a filter for a specific period to track a plan's momentum month over month.
Page views over time
const pageViews = await vanta.timeseries({
filters: filter('type', 'equals', '$page'),
interval: 'hour',
time: timeRange('2024-01-01T00:00:00Z', '2024-01-07T23:59:59Z'),
})Page view counts per hour across a week. Use day or month for longer windows.