A KPI tree for an online shop: which lever moves profit most, on one page
TL;DR
Difficulty: Advanced
A KPI tree breaks profit, by plain arithmetic, into the numbers that make it: sessions x conversion rate x contribution per order, minus ad spend and fixed costs.
- Change each lever by 1% and recalculate: in a shop with thin profit, price and margin usually move profit most, then basket size, then traffic and conversion.
- Levers fight: a 10% discount at the example shop needs 37% more orders to break even, and a bought session is only worth its contribution (40 cent at the example shop).
- Turn the profit target into a realistic target per leaf, watch the leading indicators that move first, and give every target a guardrail instead of one north star number.
- Build it as a tested Rails report on the shop's own order data and review it for 30 minutes every Monday.
Traffic, conversion, basket size, returns, ad spend: everyone has a favourite lever, and nobody can tell you which one matters most for your shop. A KPI tree can. It breaks profit into the numbers that produce it, shows what a 1% change in each one is worth in euro, and fits on one page you can review every Monday.
Which lever moves my profit most?
Every shop owner gets the same advice from every direction. Get more traffic. Lift the conversion rate. Push the basket size. Cut returns. Spend less on ads, or more. Each piece of advice is right somewhere, and none of them tells you which one matters most for your shop, this quarter, in euro.
This chapter answers that question with one tool: a KPI tree. A KPI (key performance indicator) is a number someone has agreed to steer by. A KPI tree, also called a driver tree, starts with the one number that pays the bills, profit, and breaks it into the numbers that produce it, level by level, until every branch ends in something a person can actually change. Then you can ask the tree a precise question: if this one number moves by 1%, how much does profit move?
The answer is usually surprising, and it is always specific to your shop. By the end of this chapter you will be able to draw the tree for your own shop, calculate the effect of each lever, see where the levers fight each other, set a target for each one, read the early warning signs every week, and build the whole thing as a small report that runs on your own data.
This is the last chapter of the series, and it uses the numbers from all the others. If a term is new, the glossary of every eCommerce number defines it, and ROAS, POAS and MER explains the advertising ratios that sit on one branch of the tree.
Example: Niamh's Monday question
Shannonside Home is an invented online homeware shop in Limerick (shannonsidehome.example). It sells ceramics, kitchen textiles, lamps and small furniture, about 1,400 products. Niamh owns it, and Callum is her developer. These are the example's monthly figures, and the whole chapter works with them:
| Number | Value per month |
|---|---|
| Sessions | 110,000 |
| Conversion rate | 1.8% |
| Orders | 1,980, of which 1,300 from new customers |
| Average order value, including VAT, after discounts, without delivery | €84 |
| VAT | 23% |
| Gross margin on product (on the price without VAT) | 52% |
| Orders returned | 9% |
| Fulfilment cost per order (pick, pack, packaging, carriage) | €7.50 |
| Payment fees | 1.7% of the order value |
| Handling cost per return | €10.50 |
| Ad spend | €16,500 |
| Fixed costs (salaries, rent, software, Callum's retainer) | €22,500 |
These are the same figures as in the rest of the series, and the per order numbers below are the ones the unit economics chapter builds step by step. The order value includes VAT, because that is what the customer pays, but the margin is earned on the price without VAT: VAT is Revenue's money passing through the till, not Niamh's. A return costs the handling plus the gross profit on the order, because the goods go back on the shelf but the money goes back to the customer. The returns chapter goes into what returns really cost, including write offs.
Niamh has €8,000 a month of profit in mind and makes about €5,400. The consultant who runs her ads says traffic, her developer says conversion, and a friend who runs a fashion shop in Galway says returns. Each of them is guessing, in fairness. The tree replaces the guessing.
A KPI tree breaks profit into the numbers that make it
A KPI tree is a family tree for one number. At the top sits the outcome you care about. Under it sit the two or three numbers that produce it, connected by plain arithmetic: a plus, a minus or a times. Under each of those sit its own drivers, and so on down. You stop when you reach a leaf: a number that a person can change directly with their own work, such as the price of a lamp, the cost of a parcel or the words on a product page.
The arithmetic is the whole point. In a tree, every node is calculated exactly from its children. That is what separates it from a dashboard, where the numbers sit side by side and nobody knows how they relate. If you know the arithmetic, you know what a change at the bottom does at the top.
For an online shop the top of the tree is operating profit for the month, and it splits like this (Foundations: ratios and rates):
where is the operating profit for the month, is the number of sessions (visits to the shop), is the conversion rate (the share of sessions that end in an order), is the number of orders, is the contribution per order (what an order leaves behind after every cost that comes with it), is the ad spend and is the fixed costs that do not change with the number of orders.
The contribution per order, , is its own small tree:
where is the gross profit per order, is the average order value (AOV) including VAT, is the VAT rate, is the gross margin on product (the share of the price without VAT left after the cost of the goods), is the payment fee as a share of the order value, is the fulfilment cost per order, is the return rate (the share of orders sent back) and is the handling cost of one return. The last term is the expected cost of returns: in 9 of every 100 orders you pay the handling and lose the gross profit. Foundations: ratios and rates covers the arithmetic behind each term. The unit economics chapter builds this number in full detail, with discounts, packaging, category differences and the breakeven return on ad spend that follows from it. Here it is one branch of the bigger picture.
Example: Shannonside's tree, worked through from the leaves up
Start at the bottom and climb.
Orders come from sessions times conversion rate, and of these 1,980 orders, 1,300 come from new customers:
so Shannonside takes orders a month. Revenue including VAT is orders times the average order value, .
Now the contribution per order. Without VAT the average order is worth , and the gross profit on it is . From that, subtract payment fees (), fulfilment (€7.50) and the expected cost of returns ():
so each order leaves of contribution, the same figure the unit economics chapter arrives at. Times 1,980 orders, that is €44,431.20 of contribution before marketing. Then:
so Shannonside's operating profit is a month, roughly 4% of revenue without VAT. Here is where the money goes on the way down:
And here is the tree itself, from profit at the top to the leaves at the bottom. The highlighted path is the branch the sensitivity analysis below will point at.
Three rules keep a tree honest
A tree is only useful if it is true. Three rules keep it that way.
Rule one: every node is calculated from its children, exactly. No arrows that mean "influences somehow". If a node cannot be written as a sum, a difference or a product of the nodes under it, it is a correlation, not a branch, and it belongs in the section on leading indicators further down.
Rule two: the top of the tree must match the accounts. Build the tree from the same order data your accountant uses, then check that the profit it calculates lands close to the profit in the management accounts for the same month. If it does not, something is missing: a cost nobody put in, refunds counted twice, VAT left inside revenue. A tree that does not reconcile will send you after the wrong lever with total confidence. Is your dashboard lying to you? has a ten minute check for exactly this.
Rule three: every leaf has an owner and a lever. A leaf is finished when you can name the person who changes it and the thing they would do. "Conversion rate" is not a leaf yet in a bigger shop: it splits into the add to basket rate and the checkout completion rate, owned by different work. Stop splitting when the next split would not change who acts or what they do.
Example: Callum reconciles the tree with the accounts
Callum builds the tree for October from the shop database and gets €5,431.20. The management accounts for October say €4,599.60. The gap is €831.60, about 15.3% of profit, far too big to ignore.
He walks down the tree, comparing each node with the ledger. Revenue matches to the euro. Cost of goods matches. Fulfilment does not: the tree assumes €7.50 per order, but the courier invoices for October total €15,681.60, which is €7.92 per order. Bulky lamp parcels went up in price in September and nobody updated the figure. The difference, €831.60, is exactly the gap.
Callum replaces the assumed €7.50 with the actual courier cost per order, read monthly from the invoices. Now the tree reconciles, and it has already taught Niamh something: fulfilment is a leaf that moves, and it needs an owner. For the rest of the chapter I stay with the clean €7.50 so the numbers remain easy to follow.
The repeat customer branch grows slowly and pays for years
The tree so far treats every order alike. It is not. An order from a returning customer usually costs far less to win than one from a stranger, and returning customers are the result of decisions made months earlier. So the orders node deserves its own split:
where is all orders in the month, is the orders from first time customers and is the orders from customers who have bought before. The ad spend mostly buys . The returning orders come from the customers you already have, and how many come back depends on the repeat rate, the share of first time customers who buy again within a set time. See Foundations: percentages for working with shares of a whole.
This branch behaves differently from the rest of the tree. A better product page lifts conversion this week. A better repeat rate shows up in the returning orders over the next twelve months, one cohort at a time. The chapter on customer acquisition cost and payback explains what a new customer is worth over time, the chapter on repeat purchase and churn explains how to tell who is still a customer, and the cohort analysis chapter shows how to watch each group of customers age. In the tree, the branch simply needs to be visible, so that its slow payback is not mistaken for no payback.
Example: what one point of repeat rate is worth to Shannonside
Of Shannonside's 1,980 monthly orders, 1,300 come from new customers, so and , about 34% from returning customers. The repeat rate is 28%: of every 100 first time customers, 28 buy again within twelve months.
Suppose Niamh's post purchase emails lift the repeat rate from 28% to 29%. As a first approximation, returning orders grow in proportion to the repeat rate, so they rise by one part in 28:
so the shop gains about orders a month once the effect has worked through. At €22.44 contribution each, that is a month. But not next month. The first cohort that sees the new emails needs up to a year to show its full repeat behaviour, so the €545 builds up gradually over about twelve months. A dashboard that only shows this month's profit would call the emails a failure in week four. The tree, with the branch drawn in, tells Niamh to wait and watch the right number.
Sensitivity analysis: what a 1% change in each lever does to profit
Now the question from the start. Sensitivity analysis means changing one input of a model by a small, equal step and watching how much the output moves. Here the model is the tree, the step is a 1% improvement, and the output is profit. Because every lever gets the same step, the answers can be compared directly.
The ratio of the two percentage changes has a name, the elasticity of profit with respect to that lever:
where is the elasticity of profit with respect to lever , is the percentage change in profit and is the percentage change in the lever, here always 1%. An elasticity of 6 means that a 1% better lever gives 6% more profit. See Foundations: elasticity for the general idea.
Two details decide whether the table is honest. First, change one lever at a time and keep everything else fixed, including the costs that would really move with it, and say so. Second, be precise about what "1%" means for a rate: a return rate of 9% that improves by 1% becomes 8.91%, not 8%. The second one is a change of one percentage point, which is eleven times bigger.
Example: the sensitivity table for Shannonside
Callum changes each leaf by 1% in the favourable direction, recalculates the whole tree and writes down the change in profit. Starting profit is €5,431.20.
| Lever, improved by 1% | Profit change per month | Profit change | Elasticity |
|---|---|---|---|
| Price per item (same units sold) | €1,202.22 | 22.1% | 22.1 |
| Gross margin 1% higher (52% to 52.52%) | €639.86 | 11.8% | 11.8 |
| Average order value (more items per order) | €611.58 | 11.3% | 11.3 |
| Sessions (no extra cost) | €444.31 | 8.2% | 8.2 |
| Conversion rate (1.8% to 1.818%) | €444.31 | 8.2% | 8.2 |
| Fixed costs 1% lower | €225.00 | 4.1% | 4.1 |
| Ad spend 1% lower (no sales lost) | €165.00 | 3.0% | 3.0 |
| Returning orders 1% more | €152.59 | 2.8% | 2.8 |
| Fulfilment cost per order 1% lower | €148.50 | 2.7% | 2.7 |
| Return rate 1% lower (9% to 8.91%) | €81.99 | 1.5% | 1.5 |
Take the price row step by step. A 1% higher price with the same units sold lifts revenue including VAT by 1%, which is . Without VAT that is , and after returns stays. The cost of the goods does not change, because the same lamps and mugs leave the warehouse, so all of it is extra margin. Payment fees rise by . Net effect:
so profit rises by (the cent is rounding), which is .
Compare the average order value row. A basket 1% bigger because people buy more items brings 1% more revenue, but also 1% more cost of goods, because more goods leave. Only the margin on the extra revenue stays: , minus €28.27 of payment fees, is €611.58 (the cent is rounding). Same "AOV up 1%" on a dashboard, half the profit effect. The gross margin row lands close to it for a related reason: a margin 1% higher is worth exactly the margin on 1% more revenue, without the extra payment fee. That is why the tree splits average order value into items per order and price per item.
Sessions and conversion rate have the same effect, because both raise the number of orders by 1%, and each extra order brings €22.44: . Note the condition in the table: "no extra cost". Bought sessions are not free, and the next section shows what that changes.
Why price sits at the top, and why the order changes with your margins
Price wins in almost every shop with thin profit, because a price change goes straight to the bottom line while a volume change brings its own costs along. This is not a quirk of the example. In a much cited study of 2,463 companies, Michael Marn and Robert Rosiello of McKinsey found that a 1% price improvement, with volume unchanged, raised operating profit by 11.1% on average, far more than the same improvement in volume1.
Two warnings come with that. First, "with volume unchanged" is the hard part. Raise prices and some customers buy less, which is what the next section is about. Second, the ranking depends on your numbers. The elasticities are large because Shannonside's profit is small: any change in euro looks big against €5,431.20. A shop with a 20% profit margin would see the same euro changes as much smaller percentages. And a shop with a gross margin of 25% instead of 52% would find that volume levers lose ground, because each extra order leaves less behind. Run the table on your own tree. Do not borrow anyone else's ranking, including this one.
Example: 1% or one point, the return rate trap
The return rate row looks like it hardly matters: €81.99. That is because 1% of a 9% rate is tiny, 0.09 points. Nobody runs a project to move returns from 9% to 8.91%. A realistic returns project, better size and dimension information on furniture pages, aims for a full point, from 9% to 8%. That is worth:
so a one point lower return rate adds a month: €703.14 of gross profit that is no longer refunded plus €207.90 of handling cost saved on 19.8 fewer returns. Read every row of a sensitivity table with this question: how big a step is realistic for this lever? A 1% step for price is a few pence. A 1% step for a rate can be almost nothing. Compare levers on the effort each step really takes, which leads straight to targets.
The levers are not independent
The sensitivity table changes one lever and freezes the rest. Real levers do not sit still when you pull a neighbour. A discount lifts conversion and cuts margin. More ad spend brings more sessions at a rising cost per session. A free shipping threshold lifts the average order value and can lower conversion for small baskets. The tree tells you the size of each effect. To decide, you need both effects of the same action at once.
A discount must win back more than it gives away
A discount pulls two levers in opposite directions: conversion up, contribution per order down. The question is how much more volume you need just to stand still. If is the contribution per order before the discount and the contribution per order after it, the break even rise in orders is:
where is the percentage increase in orders needed to keep contribution unchanged, is the contribution per order at full price and is the contribution per order at the discounted price. See Foundations: marginal versus average for why the change, not the average, is what counts.
Example: a 10% sitewide sale at Shannonside
Niamh considers 10% off everything for a month. The goods cost the same, so cost of goods per order stays at . The customer pays , which is without VAT.
Gross profit per order falls to . Subtract payment fees , fulfilment €7.50 and the expected cost of returns :
so each discounted order leaves instead of . The break even increase in orders:
so the sale must bring more orders just to make the same contribution as a normal month. Conversion would have to rise from 1.80% to 2.46% on the same traffic. Put the other way: a 10% price cut needs customers to respond 3.7 times as strongly, in percentage terms, as the price moved. Whether they do is a question about your customers' price sensitivity, explained in price elasticity in plain English, and testable with a holdout, explained in experiments inside your own shop. The chapter on offers and promotions works through targeted discounts, thresholds and bundles in full.
Bought traffic is worth what the next session costs
The table says 1% more sessions adds €444.31. That is true only if the sessions are free. Most growth in sessions is bought, and bought sessions have a price that rises as you buy more of them, because every channel runs out of the best audiences first. Google's own researchers build exactly this shape, carryover and diminishing returns, into their media mix models2.
The value of a session to the tree is easy to calculate: contribution per order times conversion rate.
where is the contribution one average session brings, is the contribution per order and is the conversion rate. If the next session costs more than , buying it lowers profit, however good the platform's numbers look. See Foundations: marginal versus average.
Example: the next 1,100 paid sessions
For Shannonside, . Every average session leaves 40 cent of contribution. Turned around, this is the breakeven return on ad spend (ROAS) on revenue including VAT: every euro of ads must bring back euro of orders before it stops losing money, the breakeven the unit economics chapter derives.
Say the €16,500 of ad spend buys 45,000 paid sessions, about 37 cent each on average. Callum estimates from the bid simulators that the next 1,100 sessions (1% of all traffic) would cost 70 cent each, €770 in total, because the extra clicks come from broader searches. And if they converted as well as the average session, they would bring €444.31. They would cost €770. Net:
so buying them would lower profit by a month, and the true number is worse, because marginal traffic usually converts below average. The average cost of 37 cent sits just under the 40 cent a session is worth, so the campaign as a whole only just pays. The marginal cost of 70 cent does not come close. The chapter on ROAS, POAS and MER explains marginal against average return on ad spend, and the chapter on allocating an ad budget shows how to find the point where the next euro stops paying.
Levers multiply, so improvements compound
The top of the tree is a product: sessions times conversion times contribution per order. When two levers in a product improve together, the gain is a little more than the sum of the two gains, because each improvement also applies to the other. In general, , where and are the two percentage improvements and is the extra bit. See Foundations: compounding. For small steps the extra bit is small. For a plan with several levers it is real money, and it is the honest reason to work on two or three levers at once instead of betting everything on one.
Example: conversion and basket size together
Suppose Shannonside's conversion rate rises from 1.80% to 1.85% and the average order value rises 2% through more items, from €84 to €85.68. Alone, the conversion step brings extra orders at €22.44 each, €1,234.20. Alone, the bigger basket adds of contribution to each of the 1,980 orders, €1,223.17. Together, the 55 extra orders also carry the bigger basket:
so doing both earns a month more than the two effects added up. Small here, because the steps are small. Over a year of compounding steps across five levers, it is the difference between a plan that adds up and one that comes out ahead.
Set a target for each lever by working back from profit
A profit target on its own is a wish. Nobody can work on "profit" on a Tuesday afternoon. The tree turns it into targets for the leaves, which people can work on. The method has four steps:
- Write down the profit gap: target profit minus current profit.
- For each lever, decide a realistic step for the next quarter, using the history of that lever and what the planned work can do. Realistic means you can name the work.
- Calculate the profit effect of each step with the tree, then all steps together.
- If the total falls short, add a lever or change the target. Never inflate a step to make the sum work.
Example: the plan for Niamh's €8,000
Niamh wants €8,000 profit a month. The gap is . Callum and Niamh pick three steps they can name the work for:
| Lever | Today | Target | Work behind it | Profit effect alone |
|---|---|---|---|---|
| Conversion rate | 1.80% | 1.85% | Delivery dates and stock shown on product pages, faster checkout | €1,234.37 |
| Average order value | €84.00 | €85.68 (2% more items) | Matching sets for ceramics and textiles | €1,223.17 |
| Return rate | 9.0% | 8.5% | Room photos and exact dimensions on every furniture page | €455.52 |
Added up, the three effects come to €2,913.06. Calculated together in the tree, they give €2,966.92, because the higher conversion rate also applies to the bigger baskets. New profit: €8,398.12. The plan clears the gap with €398.12 to spare, about 15% of the gap, which is a sensible margin for a plan where not everything lands.
Notice what is not on the list. No price rise, even though price tops the sensitivity table, because Niamh raised prices in spring and does not want to test her customers again so soon. The table ranks the levers. It does not make the business decision.
Leading and lagging indicators: what you see now and what you see later
Profit is a lagging indicator: it tells you the result after the fact. By the time October's profit is known, October cannot be changed. Returns lag by weeks, because customers have time to send things back. The repeat rate lags by a year. If the weekly review looks only at these, you steer by the wake of the boat.
A leading indicator moves earlier and predicts the lagging one: the add to basket rate moves before orders do, stock availability on best sellers moves before conversion does. Robert Kaplan and David Norton built the balanced scorecard on this split: financial measures report the results of actions already taken, and operational measures are the drivers of future financial performance3. A KPI tree gives you the structure to pick the right leading indicators: for every leaf, ask what moves a week or a month before it.
A leading indicator is a prediction, not an identity. Unlike the branches of the tree, it is connected to its leaf by experience and data, not by arithmetic. So check now and then that it still predicts: plot the leading indicator against its leaf over the past months and see whether they move together. Statistical thinking for growth explains why a week's wobble is not a trend.
Example: Shannonside's leading indicators for each leaf
| Leaf (lagging) | Leading indicator | Last week | Target | How early it warns |
|---|---|---|---|---|
| Sessions | Newsletter signups per week | 410 | 400 | Weeks |
| Conversion rate | Add to basket rate | 6.8% | 7.2% | Days |
| Conversion rate | Share of the 100 best sellers in stock | 94% | 98% | Days |
| Average order value | Share of orders with items from two or more categories | 22% | 25% | Days |
| Gross margin | Share of revenue sold at a discount | 11% | under 15% | Days |
| Return rate | Return requests within 7 days, per 100 orders | 4.1 | under 4.0 | Two to four weeks |
| Fulfilment cost | Share of parcels in the bulky price band | 18% | under 18% | A month |
| Returning orders | First time customers with a second order within 90 days | 9.5% | 10% | Months |
Last week the add to basket rate fell from its usual 7.2% to 6.8%, and the share of best sellers in stock fell to 94%. Orders for the week still look normal, because the shop had a strong Monday. Two leading indicators moving together are the early warning: three of the top ten lamps are out of stock, and the product pages still show them first. Niamh moves them down the listing and chases the supplier on Monday, a week before the conversion rate would have shown the damage.
One north star number misleads an online shop
A popular idea in product management is the north star metric: one number that captures the value customers get and that everyone works towards. Amplitude, whose North Star Playbook made the idea widespread, lists three qualities: it represents the value users get from the product, it lies within the influence of product and marketing, and it is a leading indicator of revenue4. For a software product with daily use that can work well.
In a shop it rarely holds, for two reasons. First, the value a customer gets is the product itself, bought once and used for years, so there is no daily usage number that stands for it. Second, and more important, every candidate number for a shop can be raised in a way that hurts profit. The anthropologist Marilyn Strathern put the general version of this, building on the economist Charles Goodhart, in one line: when a measure becomes a target, it ceases to be a good measure5.
| If the one number is | It can be raised by | Which hurts |
|---|---|---|
| Revenue | Discounts and expensive ads | Margin and contribution |
| Orders | Small orders and free shipping on everything | Contribution per order |
| Conversion rate | Cutting the less likely traffic, discounting | Sessions and margin |
| Return on ad spend (ROAS) | Cutting prospecting, bidding only on your own brand name | New customers and future orders |
| New customers | Big first order discounts | Payback and repeat quality |
The tree is the remedy. Keep profit at the top as the result, steer by the leaves, and give every leaf target a guardrail: a second number that must not get worse while the first one improves. Conversion rate with average margin per order as the guardrail. New customers with the cost per new customer as the guardrail. The tree tells you which neighbour each lever can damage, so the guardrails write themselves.
Example: what "more orders" would have done to Shannonside
Imagine Niamh had told everyone that orders were the one number that mattered. The quickest way to more orders is a sale. Suppose a month of 10% off everything lifts orders by 20%, a good response by most standards: from 1,980 to 2,376 orders. Each order now leaves €16.36, as calculated earlier. Then:
so profit falls to , a small loss. Orders up 20%, profit gone. Everyone who was told to raise orders did their job well, and the business paid for the privilege that month. With a margin guardrail, contribution per order not below €20, the sale would have been flagged on day one.
A weekly review that takes 30 minutes
The tree earns its keep in a routine. A good one is short on purpose: one fixed slot a week, the same order every time, and a log of what was decided. Thirty minutes is enough, because the tree tells you where not to look.
- Check the top. Contribution after marketing for the last full week against the target and the same week last year. Weekly, not monthly, so problems surface while they can still be fixed.
- If it is on target, scan the leading indicators for anything moving two weeks in a row, and stop there.
- If it is off target, walk down the tree. Was it volume (orders) or value (contribution per order)? Then one level further: sessions or conversion, average order value or margin or costs. Follow the branch that explains most of the gap and ignore the rest.
- Before acting, rule out a measurement fault. A tag that stopped firing or an import that failed looks exactly like a real drop.
- Decide one action per problem, with one owner and a date, and write it in the log. Next week, the first item is what happened to last week's actions.
Example: a Monday in March
Shannonside's target for contribution after marketing is €6,500 a week, after about €3,810 of weekly ad spend. Last week it was €4,894.80, which is €1,605.20 short. Same week last year: €6,200.
Niamh walks down. Orders were 468, against a usual 460, so volume is fine. Contribution per order was €18.60 against the usual €22.44, a drop of €3.84 on 468 orders, which is €1,797.12. That alone explains more than the whole gap, so the branch is value per order, and sessions and conversion can be ignored this week.
One level further: average order value was normal, fulfilment cost was normal. Gross margin after returns was down. The share of revenue sold at a discount, a leading indicator, had jumped from 11% to 24%. The cause: an end of line sale on sideboards had been left running after the stock it was meant to clear had sold out, so the discount code now applied to the new range. Not a data fault, the orders in the database confirm it.
One action: Callum limits the code to the end of line products, owner Callum, by Tuesday noon. Logged. Thirty minutes, and nobody spent the week debating traffic.
Building the tree as a small Rails report
A tree in a spreadsheet works for a start. It breaks the day someone forgets to paste in the new month. The better home is a small report inside the shop's own application, reading the same orders the accountant reads. The shops I build run on Ruby on Rails and Solidus, so every order, refund and return already sits in the shop's own database, in tables the business owns. The shop database as the source of truth explains why that matters for every number in this series.
I work test first, so the tree starts as a plain Ruby object with a test, before it touches any data. The object holds the drivers and calculates profit exactly as the formulas above do:
# app/models/kpi_tree.rb
class KpiTree
DRIVERS = %i[sessions conversion_rate average_order_value vat_rate gross_margin
return_rate payment_fee_rate fulfilment_cost return_handling_cost
ad_spend fixed_costs].freeze
# The levers the sensitivity table moves. The VAT rate is not one of them.
LEVERS = (DRIVERS - %i[vat_rate]).freeze
COSTS = %i[return_rate payment_fee_rate fulfilment_cost return_handling_cost
ad_spend fixed_costs].freeze
attr_reader :drivers
def initialize(**drivers)
@drivers = drivers.slice(*DRIVERS)
end
def orders = d(:sessions) * d(:conversion_rate)
def gross_profit_per_order
d(:average_order_value) / (1 + d(:vat_rate)) * d(:gross_margin)
end
# Gross profit, minus payment fees and fulfilment, minus the expected cost of
# returns (the handling plus the gross profit that goes back to the customer).
def contribution_per_order
g = gross_profit_per_order
g - d(:payment_fee_rate) * d(:average_order_value) - d(:fulfilment_cost) -
d(:return_rate) * (d(:return_handling_cost) + g)
end
def profit = orders * contribution_per_order - d(:ad_spend) - d(:fixed_costs)
# Profit change when each lever improves by 1% (costs go down, the rest up).
def sensitivity(step = 0.01)
LEVERS.to_h do |key|
factor = COSTS.include?(key) ? 1 - step : 1 + step
changed = self.class.new(**drivers.merge(key => d(key) * factor))
[key, (changed.profit - profit).round(2)]
end
end
private
def d(key) = drivers.fetch(key)
end
The class does three things. orders and contribution_per_order are the two branches, and gross_profit_per_order takes the VAT out before it applies the margin, exactly as in the formula. profit combines them with ad spend and fixed costs. sensitivity builds a copy of the tree with one lever moved by 1%, in the favourable direction, and records how much profit changes. The VAT rate stays fixed, because nobody in the shop can pull it. Because every number comes from the one profit method, the table can never disagree with the tree.
The test pins the example numbers from this chapter, the same ones the unit economics chapter uses, so a later change to the formula cannot silently change the answer:
# test/models/kpi_tree_test.rb
require "test_helper"
class KpiTreeTest < ActiveSupport::TestCase
setup do
@tree = KpiTree.new(
sessions: 110_000, conversion_rate: 0.018, average_order_value: 84,
vat_rate: 0.23, gross_margin: 0.52, return_rate: 0.09,
payment_fee_rate: 0.017, fulfilment_cost: 7.5, return_handling_cost: 10.5,
ad_spend: 16_500, fixed_costs: 22_500
)
end
test "profit matches the worked example" do
assert_in_delta 1_980, @tree.orders, 0.001
assert_in_delta 22.44, @tree.contribution_per_order, 0.005
# The text multiplies the rounded €22.44 by 1,980 (€5,431.20). Unrounded, the tree gives €5,437.33.
assert_in_delta 5_437.33, @tree.profit, 0.01
end
test "conversion and sessions move profit by the same amount" do
s = @tree.sensitivity
assert_equal s[:sessions], s[:conversion_rate]
assert_in_delta 444.37, s[:sessions], 0.01
end
end
Then the report fills the drivers from real data. Orders, line items and refunds come from Solidus. Spree::Order.complete selects completed orders, and the line items carry the price, the quantity, the promotion total, the VAT included in the price and the cost price, all as columns in the Solidus schema6. Sums run in the database with Active Record calculations7. Sessions do not live in the shop database. They come from Google Analytics 4, whose Data API reports a sessions metric by date8, so Callum imports them nightly into a small table of his own. Ad spend arrives the same way from the ad platforms.
# app/reports/kpi_tree_report.rb
class KpiTreeReport
def initialize(range, settings: KpiSettings.current)
@range = range
@settings = settings
end
def tree
KpiTree.new(
sessions: sessions, conversion_rate: orders.count.fdiv(sessions),
average_order_value: gross_revenue.fdiv(orders.count),
vat_rate: @settings.vat_rate,
gross_margin: 1 - cost_of_goods.fdiv(gross_revenue - included_vat),
return_rate: returned_orders.fdiv(orders.count),
payment_fee_rate: @settings.payment_fee_rate,
fulfilment_cost: @settings.fulfilment_cost_per_order,
return_handling_cost: @settings.return_handling_cost,
ad_spend: AdSpend.where(date: @range).sum(:amount),
fixed_costs: @settings.fixed_costs_for(@range)
)
end
private
def orders = Spree::Order.complete.where(completed_at: @range)
def line_items = Spree::LineItem.joins(:order).merge(orders)
# What customers paid for the goods: price times quantity, plus promotions
# (stored as negative amounts), VAT included, delivery excluded
def gross_revenue
line_items.sum(Arel.sql(
"spree_line_items.price * spree_line_items.quantity + spree_line_items.promo_total"
))
end
def included_vat = line_items.sum(:included_tax_total)
def cost_of_goods
line_items.sum(Arel.sql("COALESCE(spree_line_items.cost_price, 0) * spree_line_items.quantity"))
end
def returned_orders = Spree::Reimbursement.where(order_id: orders.select(:id)).distinct.count(:order_id)
def sessions = DailyTraffic.where(date: @range).sum(:sessions)
end
A few points for whoever maintains it. DailyTraffic, AdSpend and KpiSettings are the shop's own small models, not part of Solidus: two import tables and one place for the rates and costs that live outside the order data, such as the VAT rate, the payment fee rate, the courier cost per order and the monthly fixed costs. The return rate here counts orders from the period that have had a reimbursement, so last week's figure keeps rising for a few weeks as returns arrive; that is the lag described above, visible in the data. And the cost price must be filled in for every variant, which is why the query treats a missing one as zero and why the reconciliation in rule two matters: a zero cost price makes margin look wonderful.
With this in place, KpiTreeReport.new(1.week.ago.all_week).tree.sensitivity gives the sensitivity table for last week, from live data, in one line. Show it on an admin page next to the leading indicators, and the Monday review has everything on one screen. If the numbers in the report disagree with Google Analytics or the ad platforms, when analytics, ads and orders disagree explains which to trust for what. And if you want to see the tree as a chart, charts for analytics and marketing covers how to draw each part honestly.
Conclusion
A KPI tree takes the one number that pays the bills and breaks it, by plain arithmetic, into the numbers that make it, until every branch ends in something a person can change. Draw it from the same data as the accounts, and check it adds up. Then ask it what a 1% improvement in each lever does to profit: in a shop with thin profit, price and margin usually lead, conversion and sessions follow, and the repeat branch pays slowly but for years. Remember that levers pull on each other: a 10% discount at Shannonside needs 37% more orders to break even, and a bought session is only worth buying below its 40 cent of contribution. Turn the profit target into a realistic target for each leaf, watch the leading indicators that move before the leaves do, keep profit as the result rather than one north star number, and give every target a guardrail. Thirty minutes every Monday, walking down the tree, is enough to know which lever to pull this week.