Beyond Subscriptions to Usage
This guide will show you how to build a powerful "SaaS monetization stack." We will go beyond simple subscriptions. We will focus on implementing usage-based billing. We will use a style of tracking that captures rich details, much like Moesif does.
Based Profit with Moesif-Style Tracking
This guide will show you how to build a powerful "SaaS monetization stack." We will go beyond simple subscriptions. We will focus on implementing usage-based billing. We will use a style of tracking that captures rich details, much like Moesif does. This will help you measure API calls, storage use, and more. Follow these steps to build a more flexible and profitable billing system.
Step 1: Pinpoint Your Product's Core Value Metrics
Before you charge for usage, you must know what your customers truly value and use. Your goal is to find metrics that directly link to how much benefit a user gets from your product. This is not about busy work; it's about core value.
How to Do It:
- Look at What Matters Most: Think about what parts of your software cost you money to provide or what actions unlock big benefits for users.
- Talk to Your Customers: Ask them what features they use most. Find out what parts of your service they cannot live without.
- Check Existing Analytics: If you already track some things, see what data shows high engagement or critical operations.
Examples of Core Value Metrics:
- For an API Service: Number of API calls, specific API endpoints used, amount of data transferred in/out, compute time per request.
- For a Storage Service: Gigabytes of storage used, number of files stored, amount of data retrieved.
- For a Communication Tool: Number of messages sent, number of active users, minutes of voice/video calls.
- For an AI Platform: Number of queries processed, complexity of models run, amount of GPU time used.
Framework: The "Value Drivers" Checklist
- What problem does your product solve? Identify the main solutions.
- What resources does solving this problem consume? (e.g., server time, bandwidth, human support).
- What specific user actions indicate higher value received? (e.g., processing more images, storing more client data).
- Are there clear unit costs associated with these actions? (e.g., $X per API call, $Y per GB).
Action: Choose 2-3 key metrics you will track for usage. For this guide, let's pick "API calls" and "storage usage."
Step 2: Set Up Detailed Event Tracking (Moesif-Style)
This is the technical heart of usage-based billing. You need to record every relevant user action as an "event." Think of it like taking a snapshot of what happened. Moesif is a great tool for this, but you can build similar tracking yourself. The key is to capture rich details, not just basic counts.
What an Event Log Should Contain:
Every time a user performs an action you want to track, send an event. Each event should have:
- userId: Who performed the action.
- timestamp: When the action happened (very important for billing periods).
- eventType: What kind of action it was (e.g., API_CALL, FILE_UPLOAD, DATA_RETRIEVAL).
- properties: This is where the "Moesif-style" comes in. Include all relevant details.
- For an API_CALL: apiPath, httpMethod, statusCode, latencyMs, requestSizeKB, responseSizeKB, isAuthenticated.
- For a FILE_UPLOAD: fileName, fileSizeKB, fileType, storageLocation.
- For DATA_RETRIEVAL: dataAmountGB, databaseName.
How to Implement It (Example using Python logic):
You will embed tracking code within your application's logic. Whenever a billable action occurs, your code sends an event to your event tracking system. This system could be a dedicated analytics platform, a simple logging service, or a custom API endpoint you build.
import datetime
import requests # Used to send data to your tracking endpoint
# Assume you have a central endpoint for event logging
EVENT_TRACKING_URL = "https://your-event-tracker.com/api/v1/events"
YOUR_API_KEY = "your_secure_api_key" # For authenticating your app to the tracker
def track_event(user_id: str, event_type: str, properties: dict):
"""
Sends a detailed event to your tracking service.
"""
event_data = {
"userId": user_id,
"timestamp": datetime.datetime.now().isoformat(),
"eventType": event_type,
"properties": properties,
"appSource": "your-saas-backend" # Good for identifying where the event came from
}
try:
response = requests.post(
EVENT_TRACKING_URL,
json=event_data,
headers={"Authorization": f"Bearer {YOUR_API_KEY}"}
)
response.raise_for_status() # Raise an exception for bad status codes
print(f"Event '{event_type}' for user '{user_id}' tracked successfully.")
except requests.exceptions.RequestException as e:
print(f"Error tracking event: {e}")
# --- Usage Examples in Your Application ---
# When a user makes an API call through your service
def process_user_api_request(user, request_data, response_data, endpoint):
# ... your core API processing logic ...
latency_ms = calculate_latency() # Imagine you measure this
req_size = get_request_size(request_data)
res_size = get_response_size(response_data)
http_status = get_http_status_code()
track_event(
user_id=user.id,
event_type="API_CALL",
properties={
"apiPath": endpoint,
"httpMethod": "POST",
"statusCode": http_status,
"latencyMs": latency_ms,
"requestSizeKB": req_size,
"responseSizeKB": res_size,
"clientIP": "192.168.1.1" # Example additional useful property
}
)
# When a user uploads a file to your storage service
def handle_file_upload(user, file_metadata):
# ... your file upload processing logic ...
track_event(
user_id=user.id,
event_type="STORAGE_UPDATE",
properties={
"fileName": file_metadata["name"],
"fileSizeKB": file_metadata["size_kb"],
"fileType": file_metadata["type"],
"action": "UPLOAD", # Differentiate from downloads, deletes
"storageBucket": "primary-data"
}
)
# For current storage usage, you might log the *state* regularly,
# or calculate it from sum of UPLOADS and DELIVERS events.
# For simplicity, here we show an example of a periodic update.
def record_current_storage_snapshot(user, current_bytes_used):
track_event(
user_id=user.id,
event_type="STORAGE_SNAPSHOT",
properties={
"currentUsageBytes": current_bytes_used,
"timestamp": datetime.datetime.now().isoformat()
}
)
Action: Identify where in your code billable actions happen and add event tracking. Use a unique userId to link events to specific customers. This userId is crucial for SaaS monetization.
Step 3: Build Data Aggregation and Metering
You now have a stream of raw events. But your billing system needs simple, clear numbers for each customer. This step turns all those small events into bigger, billable units. This process is called "metering" or "meter data management."
How to Do It:
You will build a system that reads your event stream and adds up usage per user over specific periods (e.g., daily, hourly).
- Set Up a Data Pipeline: You need a way to take events from your tracking system and process them.
- Simple: A daily batch job that reads all events from yesterday, processes them, and stores the summed-up usage.
- Advanced: A streaming data solution (like Apache Kafka + Apache Flink or a cloud-based service like AWS Kinesis + Lambda) to process events in near real-time. This is useful for large volumes or if you want real-time dashboards for customers.
- Aggregate Data: For each user and for each billing metric, sum up the relevant values.
- For "API calls": Count the total API_CALL events for each user.
- For "Storage usage": This is trickier. You likely need to keep a running total or record snapshots. If using snapshots, you could charge based on the peak storage used within a billing period or the average. If tracking UPLOAD/DELETE events, sum fileSizeKB for uploads and subtract for deletes to get a current total.
Example Aggregation Logic (Conceptual):
Let's assume you want to calculate daily usage.
For each day:
For each user_id:
Initialize total_api_calls_today = 0
Initialize current_storage_bytes = 0 # This needs to persist or be calculated
Retrieve all "API_CALL" events for user_id on this day:
For each API_CALL event:
Increment total_api_calls_today
Retrieve latest "STORAGE_SNAPSHOT" event for user_id before this day (or from persistent storage):
Set current_storage_bytes to that snapshot's value.
Retrieve all "STORAGE_UPDATE" events for user_id on this day:
For each STORAGE_UPDATE event:
If event.action == "UPLOAD":
current_storage_bytes += event.properties.fileSizeKB
If event.action == "DELETE":
current_storage_bytes -= event.properties.fileSizeKB
Store daily usage for user_id:
- date: YYYY-MM-DD
- userId: user_id
- metric_api_calls: total_api_calls_today
- metric_storage_bytes_at_end_of_day: current_storage_bytes
IGNORE_WHEN_COPYING_STARTcontent_copydownload Use code with caution.IGNORE_WHEN_COPYING_END
Action: Set up a scheduled process that collects raw events and transforms them into clear, summed-up metrics for each user, ready for billing. Store this aggregated data in a database where your billing system can access it.
Step 4: Design Your Usage-Based Pricing Tiers
With usage data ready, you can now define how you will charge customers. This is more than just a single price per unit; it involves how you bundle and present that cost. Your pricing strategy is key for revenue growth and customer satisfaction.
Common Usage-Based Pricing Models:
- Pure Pay-as-You-Go: Customers pay a set price for every unit consumed (e.g., $0.001 per API call, $0.05 per GB-month of storage). This offers maximum flexibility and fairness.
- Tiered Usage: Customers get a certain amount of usage included in a base price, then pay an extra rate for usage above that amount.
- Example: First 1 million API calls included, then $5 per additional 100,000 calls.
- Volume Pricing: The price per unit decreases as usage increases (e.g., first 1 million calls cost $X each, next 5 million calls cost $Y each, where Y < X). This rewards high-volume users.
- Hybrid Models: Combine a fixed subscription fee with usage-based charges. This is often the most common way companies begin their usage-based journey.
- Example: $99/month for unlimited basic features, plus $0.001 per advanced API call and $0.02 per GB-month storage.
Considerations for Design:
- Customer Perception: Is the pricing easy to understand? Do customers see the value they get for the money? Avoid "bill shock."
- Free Tier/Trial: Offer some free usage to let new users experience your product without commitment.
- Granularity: Should you bill per second, minute, call, GB? Match the granularity to your value metrics.
- Minimum Fees: Sometimes a small minimum fee ensures revenue from low-usage customers.
- Overages: How will you charge for usage above a set limit or included amount?
- Discounts: Offer discounts for higher volume or long-term contracts.
Framework: The "Pricing Canvas"
- Metric Name: (e.g., API Calls, Storage GB)
- Base Price/Included Amount: (e.g., $50/month includes 1M calls)
- Per-Unit Rate: (e.g., $0.001 per API call after free tier)
- Tier Breaks (if any): (e.g., 1M, 5M, 10M calls)
- Per-Unit Rate at Each Tier: (e.g., Tier 1: $0.001; Tier 2: $0.0008)
- Edge Cases: What if usage is very low? What if it's extremely high?
Action: Decide on your pricing model(s) for your key usage metrics. Document these clearly. Your business goals should guide this choice.
Step 5: Integrate with a Flexible Billing System
You have events and aggregated usage. Now, you need to connect this data to a system that handles invoices, payments, and customer accounts. Traditional subscription-only billing platforms might not work for complex usage models. You need one that supports usage-based billing.
Key Features Your Billing System Needs:
- Metered Billing Support: The system must accept usage data for each customer for each metric.
- Usage Accumulation: It should accumulate usage data over a billing period (e.g., a month).
- Proration: Handles mid-period upgrades, downgrades, or cancellations fairly.
- Tiered/Volume Pricing Logic: Applies your defined pricing rules (from Step 4) to the accumulated usage.
- Automated Invoicing: Generates accurate invoices showing both fixed fees and usage charges.
- Payment Processing: Integrates with payment gateways (Stripe, Braintree, etc.).
- Customer Portal: Allows customers to see their usage and upcoming bills.
How to Integrate:
Most modern billing systems (like Stripe Billing, Paddle, Chargebee, or custom solutions) provide APIs for you to submit usage records.
Example Integration (Conceptual with a generic API):
Once a day (or hour), your data aggregation system (from Step 3) sends the summed usage for each customer to your billing system.
import requests
BILLING_API_URL = "https://your-billing-system.com/api/v1/usage_records"
BILLING_API_KEY = "your_billing_system_api_key"
def submit_usage_to_billing(user_id: str, date: str, api_calls: int, storage_bytes: int):
"""
Submits aggregated usage data to the billing system.
"""
usage_record = {
"userId": user_id,
"date": date, # The date for which usage is reported
"metrics": {
"api_calls": api_calls,
"storage_gb": storage_bytes / (1024 * 1024 * 1024) # Convert bytes to GB
}
}
try:
response = requests.post(
BILLING_API_URL,
json=usage_record,
headers={"Authorization": f"Bearer {BILLING_API_KEY}"}
)
response.raise_for_status()
print(f"Usage for user '{user_id}' on {date} submitted to billing.")
except requests.exceptions.RequestException as e:
print(f"Error submitting usage to billing: {e}")
# In your daily aggregation job:
# ... (after calculating daily_api_calls and end_of_day_storage_bytes for a user)
# submit_usage_to_billing(
# user_id=user.id,
# date=today_date_str,
# api_calls=daily_api_calls,
# storage_bytes=end_of_day_storage_bytes
# )
IGNORE_WHEN_COPYING_STARTcontent_copydownload Use code with caution. PythonIGNORE_WHEN_COPYING_END
Action: Choose a billing system that fits your needs. Then, write the code to securely send your aggregated usage data to it regularly. This is how you convert usage data into actual money.
Step 6: Monitor, Analyze, and Iterate for Profit
Launching usage-based billing is not a one-time task. It requires ongoing monitoring and analysis. This final step is crucial for fine-tuning your monetization strategy, optimizing profitability, and ensuring customer satisfaction. You need clear visibility into usage and revenue.
How to Do It:
- Build Dashboards: Create easy-to-read dashboards showing:
- Customer Usage: Who uses what and how much. Identify your heaviest users and your least engaged ones.
- Revenue Breakdown: How much revenue comes from base fees versus usage. See which usage metrics drive the most profit.
- Costs: Monitor the infrastructure costs linked to high usage.
- Trends: Watch how usage grows over time for different customer segments.
- Monitor for Anomalies: Look for sudden spikes or drops in usage. These could signal a problem, a bug, or an opportunity.
- Analyze Customer Behavior:
- Cohort Analysis: How does usage change for groups of customers acquired at the same time?
- Feature Adoption: Do customers using specific features consume more billable resources?
- Churn Risk: Are customers whose usage drops at higher risk of leaving?
- Gather Feedback: Talk to customers about their billing experience. Do they understand their bills? Do they feel the pricing is fair?
- A/B Test Pricing (Carefully): For existing customers, inform them of changes. For new sign-ups, you might test different pricing models.
Questions to Ask Yourself Regularly:
- Are customers getting good value from their usage?
- Is our SaaS monetization profitable for all types of users?
- Are we charging too little for heavy users or too much for light users?
- Does our usage-based model clearly link to customer value?
- Can customers easily forecast their bill based on their planned usage?
Action: Implement tools for data visualization and analysis. Set up regular review meetings to discuss usage trends and revenue performance. Be ready to adjust your pricing, offer new packages, or even change how you meter if data shows it will improve profit or customer happiness. Iteration is key for success in usage-based SaaS monetization.
This transition needs work and planning. But the benefits, like increased revenue growth, better alignment with customer value, and improved flexibility in your monetization stack, are well worth it. Action builds business. Start small, start smart—then scale.
This content is AI-assisted and reviewed for accuracy, but errors may occur. Always consult a legal/financial professional before making business decisions. nrold.com is not liable for any actions taken based on this information.