How do you calculate gross margin per order?
Last updated: 27 October 2026
The gross margin of an order is its revenue, excluding VAT, minus the cost of the goods in it. Subtract the cost of shipping and handling as well, and you see what the order really earns. We call that the gross margin after order costs; in the literature it is the contribution margin. The formula is simple. The work is in the data underneath.
The formula
- Gross margin = revenue excluding VAT − cost of goods
- Gross margin after order costs = gross margin − shipping costs + shipping revenue − other order costs
- Gross margin as a percentage = gross margin ÷ revenue × 100
Worked example: an order of €100 excluding VAT, with €60 cost of goods, €7 shipping costs and €5 shipping revenue. The gross margin is €40, or 40%. After order costs €38 is left, or 38%.
Always calculate excluding VAT. The VAT is not yours, and revenue including VAT next to a cost of goods excluding VAT gives a margin that means nothing.
Why it goes wrong in practice
A calculation that is correct can still produce a wrong number. We came across these four mistakes in a real month-end close of an e-commerce business. None of them looked wrong.
1. “Price” turned out to be the line total. In the order system, the selling price and the cost price were not unit prices but line totals excluding VAT. Multiply them by the quantity and you double the margin on every line with more than one item. You prove it with the VAT column: VAT divided by revenue should give the known rates.
2. A key that is not unique counts money twice. Shipping costs ran from tracking number via box to order. The box file contained duplicate tracking numbers, so parcels counted more than once and carrier costs came out too high. There was no error message; only the total no longer matched.
3. Spreading order costs creates loss-making products that do not exist. Packaging and shipping were spread over the lines of an order. One-cent promotional lines took a share of the costs and appeared as products with a loss. Margin exists at order level. A margin per line is an allocation, and it should be called one.
4. Costs complete, revenue half. One brand looked structurally loss-making while all its costs were in. The shipping and handling charged on to business customers was not in the order system but in a separate invoice specification. With that revenue added, the margin turned around.
How Sento calculates it
- Everything hangs on the order. Every revenue item and every cost that belongs to an order, from cost of goods to the line on the carrier invoice.
- Invoiced and estimated stay apart. If the carrier invoice is not in yet, Sento uses the expected shipping costs and says that it is an expectation. When the invoice arrives, it replaces the expectation.
- Shipping revenue stays apart from product revenue. So the margin per product is not polluted by something that does not belong to it.
- Empty is not zero. A line without a cost price does not count as 100% margin. The figure says which share of your revenue it covers.
- Never counted twice. Lines are de-duplicated within an invoice and never across invoices, so a correction sent later cannot hit your costs twice.
- Every amount clicks through. For every number you see which file and which line it came from.
Frequently asked questions
What is the difference between gross margin and contribution margin?
Gross margin only subtracts the cost of goods from revenue. Contribution margin also subtracts the costs that arise per order, such as shipping and handling. For an online store the second says more, because a product with a healthy gross margin can keep little after shipping.
Do I calculate margin with or without VAT?
Without VAT, for both revenue and cost of goods. Check per column whether an amount includes or excludes VAT. It is not always stated, and exports differ.
Does shipping revenue belong to revenue?
In your result, yes; in your product margin, no. Keep it separate, so the margin per product stays clean and the gross margin after order costs shows whether shipping costs you money or earns it.
Can I not just do this in Excel?
Once, yes. Every month again, with a few hundred thousand carrier lines and an invoice that arrives two weeks later, it becomes a full day nobody wants.
Want to see what is left per order in your own numbers?