Segmentation
Slice and analyze AI metrics across multiple business dimensions to uncover actionable insights
Segmentation
Segmentation is the practice of breaking down aggregate metrics into meaningful subgroups to reveal patterns, outliers, and opportunities hidden in the averages. While top-line numbers tell you whether your AI is profitable overall, segmentation tells you which customers, agents, features, and time periods drive profitability—and which don't. This granular visibility transforms data into strategy.
Why Segmentation Matters
Averages lie. Consider this scenario:
Overall metrics:
- Total revenue: $100,000
- Total cost: $20,000
- Gross margin: 80% ✓ Looks great!
But with segmentation:
| Customer Segment | Revenue | Cost | Margin | Margin % |
|-----------------|----------|----------|----------|----------|
| Enterprise | $80,000 | $10,000 | $70,000 | 87.5% |
| SMB | $15,000 | $5,000 | $10,000 | 66.7% |
| Free Tier | $5,000 | $5,000 | $0 | 0% |Suddenly you see:
- Enterprise customers are extremely profitable (87.5% margin)
- SMB customers are viable (67% margin)
- Free tier is break-even, not loss-making as feared
Actionable insight: Focus sales efforts on enterprise, optimize SMB workflows to improve margins, and maintain free tier as efficient lead gen.
Without segmentation, you might have wrongly concluded "AI is profitable, keep doing what we're doing." With segmentation, you know where to double down and where to optimize.
Core Segmentation Dimensions
LensAI provides powerful built-in segmentation capabilities across key dimensions:
By Customer
The most critical segmentation for SaaS businesses. Break down metrics by individual customers or customer cohorts:
Individual customer analysis:
const customerMetrics = await client.analytics.getMetrics({
dimension: 'customer',
customer_id: 'user_123',
period: 'last_30_days'
});
// Returns:
// {
// cost: 12.50,
// revenue: 50.00,
// value_delivered: 200.00,
// margin: 37.50,
// margin_percent: 75.0,
// requests: 450,
// sessions: 23
// }Customer cohort analysis:
const cohortMetrics = await client.analytics.getMetrics({
dimension: 'customer',
segment_by: 'plan_tier',
period: 'last_30_days'
});
// Returns metrics grouped by: enterprise, pro, starter, freeUse customer segmentation to:
- Identify your most profitable customers
- Detect customers at risk of churn (high cost, low engagement)
- Target upsell opportunities (high usage, low-tier plan)
- Optimize support (focus on high-value customers)
By Agent
Understand which AI agents deliver the best returns:
const agentMetrics = await client.analytics.getMetrics({
dimension: 'agent',
period: 'last_30_days'
});
// Returns metrics for: customer_support, sales_assistant, code_generator, etc.Example analysis:
| Agent | Cost | Value | Value/Cost | Goal Rate |
|--------------------|---------|-----------|------------|-----------|
| customer_support | $2,000 | $15,000 | 7.5x | 85% |
| sales_assistant | $5,000 | $30,000 | 6.0x | 72% |
| code_generator | $800 | $10,000 | 12.5x | 90% |
| content_writer | $1,200 | $3,000 | 2.5x | 60% |Insights:
- Code generator has best ROI (12.5x value/cost) and highest goal achievement
- Content writer has weakest ROI and lowest goal achievement → prioritize optimization
- Customer support has solid metrics → scale up
By Time
Temporal segmentation reveals trends, seasonality, and anomalies:
Time-series analysis:
const timeSeriesMetrics = await client.analytics.getTimeSeries({
dimension: 'day',
period: 'last_90_days',
metrics: ['cost', 'revenue', 'value', 'margin']
});
// Returns daily metrics for the last 90 daysUse time segmentation to:
- Spot trends: Is cost growing faster than revenue?
- Identify seasonality: Do costs spike on weekends? End of month?
- Measure impact: Did optimization on March 15 reduce costs as expected?
- Forecast: Project next quarter's spend based on growth rate
Example patterns:
Week 1: $2,000 cost → Week 4: $2,200 → Week 8: $2,800 → Week 12: $3,500
Growth rate: ~11% per month
Forecasted next quarter: $3,500 × 1.11^3 ≈ $4,800/monthBy Session
Session-level segmentation helps understand interaction patterns:
const sessionMetrics = await client.analytics.getMetrics({
dimension: 'session',
filter: {
goal_achieved: true
},
period: 'last_30_days'
});
// Compare successful vs unsuccessful sessionsExample analysis:
| Session Type | Avg Cost | Avg Duration | Goal Rate | Avg Value |
|------------------|----------|--------------|-----------|-----------|
| Successful | $0.25 | 3.2 min | 100% | $50 |
| Failed | $0.18 | 1.8 min | 0% | $0 |
| Abandoned | $0.05 | 0.5 min | 0% | $0 |Insights:
- Successful sessions cost more but deliver massive value ($50 vs $0)
- Failed sessions waste resources ($0.18) without achieving goals
- Early detection of failure could reduce wasted spend
By Model
Understand cost and performance differences across LLM models:
const modelMetrics = await client.analytics.getMetrics({
dimension: 'model',
period: 'last_30_days'
});
// Returns metrics for: gpt-4, gpt-3.5-turbo, claude-3-opus, etc.Example analysis:
| Model | Cost | Requests | Avg Cost/Req | Goal Rate | Value/Cost |
|-----------------|---------|----------|--------------|-----------|------------|
| gpt-4 | $8,000 | 15,000 | $0.53 | 88% | 6.2x |
| gpt-3.5-turbo | $1,200 | 40,000 | $0.03 | 78% | 8.5x |
| claude-3-opus | $3,500 | 8,000 | $0.44 | 90% | 7.1x |Insights:
- GPT-3.5 has best value/cost ratio despite lower goal achievement
- Claude-3-opus has highest goal rate but moderate value/cost
- Opportunity: Route simple queries to GPT-3.5, complex to GPT-4 or Claude
By Geography
If you serve global customers, geographic segmentation reveals regional differences:
const geoMetrics = await client.analytics.getMetrics({
dimension: 'customer',
segment_by: 'region',
period: 'last_30_days'
});Use cases:
- Pricing adjustments by region (purchasing power parity)
- Infrastructure optimization (regional compute to reduce latency)
- Feature prioritization (which features are popular where)
By Feature or Workflow
Segment by specific features or user workflows:
await client.chat.completions.create({
model: 'gpt-4',
messages: [...],
metadata: {
feature: 'advanced_search',
workflow: 'product_discovery'
}
});
const featureMetrics = await client.analytics.getMetrics({
dimension: 'metadata.feature'
});Understand which features drive costs and value.
Multi-Dimensional Segmentation
The real power comes from combining multiple dimensions:
Customer × Agent
Which agents are most valuable for which customer segments?
const metrics = await client.analytics.getMetrics({
dimension: 'agent',
segment_by: 'customer.plan_tier',
period: 'last_30_days'
});Example insights:
Enterprise customers:
- Heavy use of sales_assistant (high deal size)
- Moderate use of customer_support (white-glove service)
SMB customers:
- Heavy use of customer_support (self-service)
- Low use of sales_assistant (no dedicated sales)Action: Optimize customer_support agent for SMB use cases, enhance sales_assistant for enterprise deals.
Time × Model
How do model costs trend over time?
const timeSeries = await client.analytics.getTimeSeries({
dimension: 'day',
segment_by: 'model',
period: 'last_90_days'
});Example pattern:
GPT-4 usage growing 5%/week (expensive model)
GPT-3.5 usage flat (we're not shifting enough traffic to cheaper model)Action: Implement intelligent routing to shift appropriate workloads to GPT-3.5.
Customer × Time (Cohort Analysis)
Track how customer cohorts evolve over their lifetime:
const cohortAnalysis = await client.analytics.getCohorts({
cohort_by: 'signup_month',
metrics: ['cost', 'revenue', 'value'],
period: 'months_since_signup',
max_period: 12
});Example insights:
Month 0 (signup): Avg cost $5, avg revenue $15, margin 67%
Month 3: Avg cost $8, avg revenue $30, margin 73%
Month 6: Avg cost $12, avg revenue $50, margin 76%
Month 12: Avg cost $15, avg revenue $80, margin 81%Pattern: Costs and revenue both grow, but revenue grows faster → improving margins over customer lifetime.
Advanced Segmentation Techniques
Percentile Analysis
Don't just look at averages—understand distribution:
const percentiles = await client.analytics.getPercentiles({
metric: 'cost_per_customer',
percentiles: [10, 50, 90, 99],
period: 'last_30_days'
});
// Returns:
// {
// p10: $2.50, // 10% of customers cost less than $2.50
// p50: $10.00, // Median
// p90: $45.00, // 10% of customers cost more than $45
// p99: $200.00 // 1% of customers cost more than $200 (outliers!)
// }Insight: If p99 is 20x the median, you have a small number of extremely expensive customers. Investigate why and consider usage limits or pricing adjustments.
RFM Segmentation (Recency, Frequency, Monetary)
Adapt classic customer segmentation to AI usage:
- Recency: When did the customer last use AI features?
- Frequency: How often do they use AI?
- Monetary: How much revenue do they generate?
const rfmSegments = await client.analytics.getRFMSegments({
recency_days: 30,
frequency_threshold: 10, // sessions per month
monetary_threshold: 50 // revenue per month
});
// Returns customers grouped into:
// - Champions (high R, F, M)
// - Loyal (high F, M)
// - At-Risk (low R, high F, M)
// - etc.Target actions based on RFM segment:
- Champions: Upsell, ask for referrals, beta test new features
- At-Risk: Re-engagement campaigns, understand why usage dropped
- Low-Value: Automated support, optimize costs
Outlier Detection
Automatically identify anomalous customers, sessions, or time periods:
const outliers = await client.analytics.getOutliers({
metric: 'cost_per_session',
threshold: 3 // Standard deviations from mean
});
// Returns sessions with cost 3+ std devs above averageUse cases:
- Detect abuse or bugs (session cost 100x normal)
- Identify edge cases to optimize (why is this query so expensive?)
- Find exceptional positive cases (super-efficient workflows to learn from)
Segmentation Best Practices
Start with business questions, not data. Don't segment for the sake of segmenting. Ask "What decision am I trying to make?" and segment to answer that question.
Layer dimensions progressively. Start with one dimension (e.g., customer), analyze, then add a second (e.g., customer × time), and so on. Too many dimensions at once overwhelms.
Focus on actionable segments. Interesting patterns are worthless if you can't act on them. Prioritize segments where insights can drive decisions (pricing, feature development, customer outreach).
Monitor segment stability. If a segment's metrics vary wildly week-to-week, it may be too small or poorly defined. Combine or refine.
Document segment definitions. Write down what each segment represents (e.g., "Enterprise = >$1,000 MRR, >10 seats") so everyone interprets analytics consistently.
Automate critical segments. Set up dashboards and alerts for your most important segments (e.g., alert if margin for enterprise customers drops below 75%).
Validate with qualitative data. Quantitative segmentation reveals patterns. Validate with customer interviews, surveys, and support feedback to understand the "why" behind the numbers.
Using Segmentation for Strategic Decisions
Product Roadmap Prioritization
Segment feature usage by customer value:
High-value customers heavily use feature A → Prioritize enhancing feature A
Low-value customers use feature B, high-value customers don't → Deprioritize feature BPricing Optimization
Segment cost and value by plan tier:
Starter plan: $15 revenue, $8 cost, $50 value → Underpriced, raise to $25
Pro plan: $50 revenue, $12 cost, $200 value → Well-priced, no changeCustomer Success
Segment by health score (cost, usage, goals achieved):
High-cost + low goal achievement = at-risk → Proactive outreach
High usage + low-tier plan = upsell candidate → Sales follow-upGo-To-Market Strategy
Segment new customers by acquisition channel and cost-to-serve:
Channel A: $5 CAC, $20 cost-to-serve (first month) → Net $15 cost → ROI in month 2
Channel B: $15 CAC, $8 cost-to-serve → Net $23 cost → ROI in month 3Choose channel based on payback period and customer LTV.
Next Steps
Now that you understand segmentation, you're ready to:
- Build custom dashboards that surface your most important segments
- Set up alerts for segment-level threshold breaches
- Run experiments (A/B tests) and use segmentation to measure impact
- Deep-dive into outliers to uncover optimization opportunities or bugs
Effective segmentation transforms LensAI from a cost tracking tool into a strategic intelligence platform that drives every major business decision.