Custom Metrics
Create custom metrics to track KPIs, calculate aggregations, and measure business performance.
What are Custom Metrics?
Custom metrics let you define calculations based on your event data. Instead of manually querying events, you can create reusable metrics that automatically calculate values like total revenue, average session duration, conversion rates, and more.
Metric Types
Count
Count the number of events matching your criteria.
Example: Total number of signups
- •Type: Count
- •Event Names: user_signup
Sum
Sum a numeric property across events.
Example: Total revenue
- •Type: Sum
- •Event Names: purchase_completed
- •Property Path: metadata.amount
Average
Calculate the average value of a numeric property.
Example: Average order value
- •Type: Average
- •Event Names: purchase_completed
- •Property Path: metadata.amount
Unique
Count unique values of a property (e.g., unique users, unique sessions).
Example: Daily active users
- •Type: Unique
- •Event Names: (all events)
- •Property Path: userId
Conversion Rate
Calculate the percentage of users who complete a goal event after a starting event.
Example: Signup to purchase conversion
- •Type: Conversion Rate
- •Numerator Events: purchase_completed
- •Denominator Events: user_signup
Ratio
Calculate a custom ratio between two event counts or sums.
Example: Revenue per user
- •Type: Ratio
- •Numerator: Sum of purchase_completed (metadata.amount)
- •Denominator: Unique count of userId
Creating a Metric
Navigate to Dashboard → Metrics → Create Metric and configure:
- •Name: A descriptive name for your metric
- •Description: Optional explanation of what this metric measures
- •Metric Type: Choose from count, sum, average, unique, conversion rate, or ratio
- •Event Names: Which events to include in the calculation
- •Property Path: For sum/average/unique, which property to aggregate
- •Filters: Optional conditions to filter events (e.g., metadata.plan = "pro")
- •Display Format: How to display the value (number, currency, percentage)
Using Metrics via API
Once created, query metrics programmatically:
curl -X GET "https://serla.dev/api/metrics/metric_123/calculate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"startDate": "2025-01-01T00:00:00Z",
"endDate": "2025-01-31T23:59:59Z",
"timeSeries": true,
"interval": "day"
}'Best Practices
- •Use descriptive names: "Monthly Recurring Revenue" instead of "MRR Metric"
- •Set appropriate display formats: Use currency format for revenue, percentage for rates
- •Add filters for segmentation: Create separate metrics for different user segments or plans
- •Use time series: Enable time series data to visualize trends on dashboards
- •Set goals: Define target values to track performance against objectives
Common Metric Examples
Monthly Recurring Revenue (MRR)
Sum of metadata.amount where eventName = "subscription_created" or "subscription_renewed"
- •Type: Sum
- •Event Names: subscription_created, subscription_renewed
- •Property Path: metadata.amount
- •Filters: metadata.billing_cycle = "monthly"
Churn Rate
Ratio: subscription_canceled / active_subscriptions
- •Type: Ratio
- •Numerator: Count of subscription_canceled
- •Denominator: Count of subscription_active
Trial to Paid Conversion
Conversion Rate: subscription_created (numerator) / trial_started (denominator)
- •Type: Conversion Rate
- •Numerator Events: subscription_created
- •Denominator Events: trial_started
Pro Tip: Custom metrics are available on the Pro and Max plans. Use them in custom dashboards to create comprehensive reporting views for your team.