Revenue Tracking
Track purchases and revenue from your subscribers
Lumail allows you to track purchase activity and revenue associated with your subscribers. This enables you to:
- Calculate subscriber lifetime value (LTV)
- Segment subscribers by purchase behavior
- Measure ROI of your email campaigns
- Create targeting based on purchase history
- Build automation workflows triggered by purchases
How Revenue Tracking Works
Lumail tracks revenue by recording payment events against individual subscribers. Each payment event increases the subscriber's revenue counter, providing a running total of their lifetime value.
These payment events must be manually tracked through the Events API, allowing you to integrate with your existing payment system or e-commerce platform.
Setting Up Revenue Tracking
To track revenue for your subscribers, you'll need to send payment events to Lumail when purchases occur. Here's how to set it up:
1. Implement Event Tracking in Your Payment System
When a customer makes a purchase, you'll need to:
- Identify the subscriber by email address
- Record the purchase amount and details
- Send a
SUBSCRIBER_PAYMENTevent to Lumail
2. Send Payment Events to the API
Use the Events API to send payment information:
const response = await fetch("https://lumail.io/api/v1/events", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
eventType: "SUBSCRIBER_PAYMENT",
subscriber: "customer@example.com",
data: {
amount: 49.99,
product: "Premium Subscription",
},
}),
});
Required Payment Data Fields
| Field | Type | Description |
|---|---|---|
amount | number | The payment amount (required) |
product | string | Name of the product purchased (required) |
3. Track Refunds (Optional)
If you process refunds, you should also track these using the SUBSCRIBER_REFUND event:
const response = await fetch("https://lumail.io/api/v1/events", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
eventType: "SUBSCRIBER_REFUND",
subscriber: "customer@example.com",
data: {
amount: 49.99,
product: "Premium Subscription",
},
}),
});
4. View Revenue Data
Once you've implemented revenue tracking, you can:
- See payment events in the subscriber timeline
- View total revenue per subscriber in the subscribers list
- Use revenue data for segmentation
- Create reports based on revenue metrics
Integration Examples
E-commerce Integration
If you run an e-commerce store, you can integrate revenue tracking on your order confirmation page:
// Example code to run after successful checkout
async function trackOrderInLumail(order) {
await fetch("https://lumail.io/api/v1/events", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
eventType: "SUBSCRIBER_PAYMENT",
subscriber: order.customerEmail,
data: {
amount: order.total,
product: order.items.map((item) => item.name).join(", "),
},
}),
});
}
Subscription System Integration
For subscription businesses, track recurring payments:
// Example webhook handler for subscription payment events
app.post("/webhook/payment-succeeded", async (req, res) => {
const event = req.body;
// Track the payment in Lumail
try {
await fetch("https://lumail.io/api/v1/events", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
eventType: "SUBSCRIBER_PAYMENT",
subscriber: event.customer.email,
data: {
amount: event.amount / 100, // Convert from cents
product: event.product.name,
},
}),
});
res.status(200).send("Event processed");
} catch (error) {
console.error("Error tracking payment:", error);
res.status(500).send("Error processing event");
}
});
Best Practices
- Be Consistent: Use the same format for all payment tracking
- Track Immediately: Send payment events as soon as the transaction is confirmed
- Include Product Info: Add descriptive product names to help with analysis
- Track Refunds: Always record refunds to keep revenue data accurate
- Test First: Verify your integration with test purchases before full deployment
Related Documentation
- Subscriber Events Reference - Complete guide to all event types
- Track Events API - Technical details for sending events
- Get Subscriber Events API - Retrieve payment event history
- Subscribers API - View and manage subscriber data
- ClickFunnels Integration - Track order events automatically