iconLensAI

Revenue Mapping

Connect customer payments to AI usage to calculate margins, profitability, and unit economics

Revenue Mapping

Revenue mapping connects what customers pay you to the AI usage and costs attributed to those customers. This connection transforms cost and value analytics into true business intelligence: profitability analysis, margin calculation, and unit economics. With revenue mapping, you can answer critical questions like "Are we profitable at the customer level?" and "What's our margin on AI-powered features?"

Why Revenue Mapping Matters

You can track costs perfectly. You can measure value delivered accurately. But without connecting to revenue, you don't know if your AI business is actually profitable.

Without revenue mapping:

  • You know customer X costs $5/month to serve
  • You know you deliver $50/month in value to them
  • But you don't know if you're profitable on that customer

With revenue mapping:

  • Customer X pays $15/month
  • Costs $5/month to serve (AI + infrastructure)
  • Delivers $50/month in value
  • Net margin: $10/month (67% gross margin)
  • Value delivered exceeds revenue (strong product-market fit)

This visibility enables data-driven decisions about pricing, customer acquisition costs, feature development, and growth strategy.

Types of Revenue to Track

LensAI supports multiple revenue models common in AI-powered businesses:

Subscription Revenue

Recurring monthly or annual fees:

await client.revenue.record({
  customer_id: 'user_123',
  amount: 99.00,
  currency: 'USD',
  revenue_type: 'subscription',
  billing_period_start: '2025-01-01',
  billing_period_end: '2025-01-31',
  metadata: {
    plan: 'pro',
    interval: 'monthly'
  }
});

LensAI automatically associates this revenue with all AI usage by user_123 during January 2025.

Usage-Based Revenue

Revenue that scales with consumption:

await client.revenue.record({
  customer_id: 'user_456',
  amount: 47.50,
  currency: 'USD',
  revenue_type: 'usage',
  description: 'API calls for January 2025',
  metadata: {
    units_consumed: 95000,
    rate_per_unit: 0.0005
  }
});

One-Time Payments

Setup fees, professional services, or other non-recurring charges:

await client.revenue.record({
  customer_id: 'enterprise_789',
  amount: 5000.00,
  currency: 'USD',
  revenue_type: 'one_time',
  description: 'Implementation and onboarding services'
});

Transaction Fees

Revenue from individual transactions or events:

await client.revenue.record({
  customer_id: 'user_101',
  session_id: 'payment_session_xyz',
  amount: 2.99,
  currency: 'USD',
  revenue_type: 'transaction',
  description: 'Premium AI feature usage'
});

Session-level revenue attribution allows precise margin analysis for individual interactions.

Revenue Attribution Strategies

Different business models require different approaches to attributing revenue:

Direct Attribution

The simplest case: customer pays specifically for AI features, and all their AI usage maps directly to revenue.

Example: A customer pays $50/month for an AI-powered tool. All their AI costs are attributed to the $50/month revenue.

// Record monthly subscription
await client.revenue.record({
  customer_id: 'user_123',
  amount: 50.00,
  billing_period_start: '2025-01-01',
  billing_period_end: '2025-01-31'
});

// LensAI automatically maps all January AI costs for user_123 to this revenue

Margin calculation:

Revenue: $50.00
Cost: $8.00 (AI usage for January)
Gross Margin: $42.00 (84%)

Proportional Attribution

Customer pays for a bundle that includes AI and non-AI features. Attribute a portion of revenue to AI based on usage, value, or feature mix.

Example: Customer pays $100/month for a SaaS product. You estimate 40% of value comes from AI features, so you attribute $40 to AI revenue.

await client.revenue.record({
  customer_id: 'user_456',
  amount: 100.00,
  revenue_type: 'subscription',
  metadata: {
    total_subscription: 100.00,
    ai_attributed_portion: 0.40
  }
});

// Calculate AI-attributed revenue
const aiRevenue = 100.00 * 0.40; // $40

Margin calculation:

AI-attributed Revenue: $40.00
AI Cost: $12.00
Gross Margin: $28.00 (70%)

Metered Attribution

Revenue scales directly with AI usage (tokens, requests, compute time).

Example: You charge $0.001 per API call. Customer makes 10,000 calls → $10 revenue.

// Record usage event with revenue
await client.chat.completions.create({
  model: 'gpt-4',
  messages: [...],
  metadata: {
    customer_id: 'user_789',
    billable: true,
    unit_price: 0.001
  }
});

// At end of billing period, aggregate and record revenue
const totalCalls = 10000;
const revenue = totalCalls * 0.001; // $10

await client.revenue.record({
  customer_id: 'user_789',
  amount: revenue,
  revenue_type: 'usage',
  description: 'API calls - January 2025'
});

Margin calculation (assuming LensAI cost is $0.0003 per call):

Revenue per call: $0.001
Cost per call: $0.0003
Margin per call: $0.0007 (70%)

Total revenue: $10.00
Total cost: $3.00
Gross margin: $7.00 (70%)

Value-Based Attribution

Revenue is based on value delivered, tracked via LensAI value modeling.

Example: You charge 20% of value delivered. If you deliver $500 in value, you charge $100.

// Record value delivered
await client.sessions.recordValue({
  session_id: 'session_abc',
  customer_id: 'user_202',
  value: 500.00,
  value_type: 'time_saved'
});

// Record revenue (20% of value)
await client.revenue.record({
  customer_id: 'user_202',
  session_id: 'session_abc',
  amount: 100.00,
  revenue_type: 'value_based',
  metadata: {
    value_delivered: 500.00,
    revenue_share: 0.20
  }
});

Margin calculation (assuming $5 cost):

Revenue: $100.00
Cost: $5.00
Gross Margin: $95.00 (95%)
Value-to-Revenue Ratio: 5:1 (deliver $5 value per $1 charged)

Revenue Metrics and Analytics

Once you're mapping revenue to AI usage, LensAI provides powerful financial analytics:

Revenue-to-Cost Ratio

The most direct profitability metric:

Revenue-to-Cost Ratio = Total Revenue / Total Cost

Example: Customer segment generated $50,000 in revenue and cost $12,000 to serve. Revenue-to-cost ratio: 4.17 (77% gross margin)

A ratio of:

  • < 1.0: Unprofitable—you're spending more than you earn
  • 1.0 - 2.0: Low margin—viable but tight
  • 2.0 - 5.0: Healthy margin—sustainable business
  • > 5.0: Excellent margin—strong profitability

Gross Margin

Gross Margin = (Revenue - Cost) / Revenue × 100%

Example: Revenue: $50,000 Cost: $12,000 Gross Margin: ($50,000 - $12,000) / $50,000 = 76%

For SaaS businesses, target gross margins are typically 70-90%. Below 60% may indicate pricing or cost issues.

Customer Lifetime Value (LTV)

Project future profitability by combining revenue, cost, and retention data:

LTV = (Avg Monthly Revenue × Gross Margin %) × Avg Customer Lifetime (months)

Example: Avg monthly revenue: $100 Gross margin: 75% Avg lifetime: 24 months LTV = $100 × 0.75 × 24 = $1,800

Compare LTV to Customer Acquisition Cost (CAC) to assess business health. A healthy ratio is 3:1 (LTV:CAC).

Revenue per Customer

Revenue per Customer = Total Revenue / Number of Customers

Track this over time to measure expansion revenue, upsells, and pricing effectiveness.

Cost per Customer

Cost per Customer = Total AI Cost / Number of Customers

Compare to revenue per customer to ensure healthy unit economics.

Margin by Customer Segment

Break down profitability by customer attributes:

| Segment       | Revenue | Cost   | Margin  | Margin % |
|--------------|---------|--------|---------|----------|
| Enterprise   | $50,000 | $8,000 | $42,000 | 84%      |
| SMB          | $20,000 | $6,000 | $14,000 | 70%      |
| Free Tier    | $0      | $3,000 | -$3,000 | N/A      |

This segmentation reveals:

  • Enterprise customers are most profitable
  • SMB customers are viable but lower margin
  • Free tier is subsidized (expected for freemium model)

Focus growth efforts on high-margin segments.

Pricing Strategy Based on Margin Analysis

Revenue mapping informs pricing decisions:

Cost-Plus Pricing

Set price based on cost plus target margin:

Price = Cost / (1 - Target Margin %)

Example: Average cost per customer: $10/month Target margin: 75% Price = $10 / (1 - 0.75) = $40/month

Value-Based Pricing

Price based on value delivered, ensuring healthy margin:

Price = Value Delivered × Value Capture %

Example: Value delivered: $200/month Value capture target: 20% Price = $200 × 0.20 = $40/month Cost: $10/month Margin: $30/month (75%)

Value capture of 10-30% is typical for SaaS products. Lower capture (higher customer surplus) drives adoption. Higher capture maximizes revenue.

Tiered Pricing Optimization

Use cost and value data to set tier boundaries:

| Tier      | Price/mo | Avg Cost/mo | Margin | Value Delivered |
|-----------|----------|-------------|--------|----------------|
| Free      | $0       | $2          | -$2    | $20            |
| Starter   | $15      | $5          | $10    | $50            |
| Pro       | $50      | $12         | $38    | $200           |
| Enterprise| $200     | $30         | $170   | $1,000         |

Design tier limits (usage caps, feature access) to push high-cost users to higher tiers and protect margins.

Combining Revenue, Cost, and Value

The complete picture requires all three metrics:

| Metric   | Definition                      | Business Meaning              |
|----------|--------------------------------|-------------------------------|
| Cost     | What you spend                 | Operational efficiency        |
| Value    | Benefit delivered to customer  | Product-market fit            |
| Revenue  | What customer pays you         | Monetization effectiveness    |

Ideal scenario:

  • High value delivered (strong product, real benefits)
  • Low cost to deliver (efficient operations)
  • Healthy revenue (effective pricing, willing to pay)

Warning signs:

  • Value << Revenue: Customers won't renew (overpromising)
  • Revenue << Cost: Unprofitable (pricing too low or costs too high)
  • Value >> Revenue: Leaving money on table (underprice)
  • Cost >> Revenue: Burning cash (unsustainable)

Customer-Level Profitability Matrix

Segment customers by revenue and cost:

                High Revenue
                    |
    Low Cost  [A: Dream]  |  High Cost  [B: Optimize]
              -----------  |  ----------------------
    Low Cost  [C: Grow]   |  High Cost  [D: At-Risk]
                    |
                Low Revenue

Quadrant A (High revenue, low cost): Dream customers—expand and retain Quadrant B (High revenue, high cost): Profitable but optimize to improve margin Quadrant C (Low revenue, low cost): Grow revenue through upsells Quadrant D (Low revenue, high cost): At-risk—improve efficiency or churn

Best Practices for Revenue Mapping

Capture revenue data consistently. Set up automated flows (Stripe webhooks, billing system integrations) to record revenue in LensAI whenever payments occur.

Align billing periods with cost tracking. If you bill monthly, aggregate costs monthly. This ensures accurate margin calculations.

Handle refunds and credits properly. Record negative revenue for refunds so margins reflect actual retained revenue.

await client.revenue.record({
  customer_id: 'user_123',
  amount: -50.00, // Negative for refund
  revenue_type: 'refund',
  description: 'Refund for January subscription'
});

Segment by revenue cohort. Track how revenue and margins evolve as customers mature (month 1, month 3, month 12). Early months often have lower margins as customers ramp up.

Monitor revenue concentration. If 80% of revenue comes from 20% of customers, understand the cost and value dynamics of that critical 20%.

Test pricing changes with data. Use LensAI's cost and value data to model the impact of price changes before implementing them.

Track revenue attribution accuracy. Periodically reconcile LensAI revenue data with your billing system to ensure consistency.

Advanced Revenue Mapping Scenarios

Multi-Product Attribution

Customer subscribes to multiple products, some with AI, some without:

await client.revenue.record({
  customer_id: 'user_500',
  amount: 150.00,
  revenue_type: 'subscription',
  metadata: {
    product_mix: {
      'ai_assistant': 60.00,    // AI-powered product
      'static_tools': 50.00,    // Non-AI product
      'storage': 40.00          // Non-AI product
    }
  }
});

// Only $60 of the $150 is attributed to AI costs

Revenue Forecasting

Project future revenue based on growth and retention:

const currentMonthlyRevenue = 10000;
const monthlyGrowthRate = 0.10; // 10% MoM growth
const months = 12;

let forecastedRevenue = 0;
for (let i = 0; i < months; i++) {
  forecastedRevenue += currentMonthlyRevenue * Math.pow(1 + monthlyGrowthRate, i);
}

// Forecast: ~$155,000 over next 12 months

// Compare to forecasted costs to project profitability

Dynamic Pricing Based on Cost

Adjust pricing in real-time based on cost trends:

// If average cost per customer exceeds threshold, increase price
const avgCostPerCustomer = await client.analytics.getAverageCost({
  dimension: 'customer',
  period: 'last_30_days'
});

if (avgCostPerCustomer > 20.00) {
  // Trigger pricing review or automated price adjustment
  // (with appropriate customer communication)
}

Next Steps

Now that you understand revenue mapping, explore:

  • Cost Attribution: Ensure accurate cost tracking to support margin analysis
  • Value Modeling: Understand value delivered relative to revenue charged
  • Segmentation: Analyze profitability across multiple dimensions simultaneously