Blog · Finance metrics and formulas
Ecommerce gross margin starts with net sales after discounts and returns, then deducts matched cost of sales. Work through an order and return reconciliation, check recovered inventory cost, and separate product economics from changes in sales mix.
Ecommerce gross margin is the share of net sales left after the matched cost of goods sold. Start with sales after discounts and returns, then reconcile the product costs and returned inventory before calculating the percentage. A storefront sales total or payment settlement alone does not provide that answer.
Net sales = Gross product sales − Discounts − Returns and allowances
Gross profit = Net sales − Cost of goods sold
Ecommerce gross margin = Gross profit / Net sales
This is the same underlying measure as gross profit margin. The ecommerce work is matching orders, refunds and inventory movements across the files that hold them.
The SEC's financial statement guide explains that returns and allowances reduce gross revenue to net revenue, and cost of sales is then deducted to arrive at gross profit. The denominator should therefore be net sales, rather than gross checkout value or cash deposited by a payment processor.
Document the cost boundary before comparing products. In the example below, merchandise acquisition costs, including inbound freight, enter product COGS. Advertising, outbound customer delivery, fulfillment overhead, marketplace commissions and payment processing fees sit below gross profit under this company's stated reporting policy. Those costs still matter to profitability; they are simply outside this calculation.
IRS Publication 334 includes freight-in on merchandise purchased for sale in cost of goods sold. It also describes returns and allowances as including cash or credit refunds, rebates and other sales-price allowances. Use that guidance to identify missing inputs, while having the controller confirm the company's financial-reporting classifications.
For the broader cost question, use ecommerce profit margin. Keep that comparison separate so a strong merchandise margin does not conceal expensive delivery or customer acquisition.
Bring three exports: order lines, refund or credit lines, and inventory cost movements. Each needs a product identifier, posting date, currency and original order reference where available. Preserve the transaction identifier so a refund with several status updates does not become several deductions.
The order file supplies gross product sales and discounts. The return file supplies refunds or credits and the original sale reference. The cost file supplies the original cost relieved from inventory and the amount restored when merchandise is accepted back.
Use posted reporting-period amounts for a ledger comparison. Include return allowance adjustments if the ledger has them. An order-cohort view can answer a different commercial question, but label its sales window and return observation date rather than expecting it to equal the monthly P&L automatically.
Exclude canceled orders that never became sales. Keep sales tax collected for the government outside this example's product sales. If customer shipping charges are recorded as revenue in your ledger, include and label them consistently rather than dropping them to match a storefront subtotal.
A US home-goods retailer reports two product lines for one month. All rows are posted in the same reporting period, and there are no additional return allowance movements. Refunds below exclude discounts already deducted, preventing the same price reduction from being counted twice.
| Product | Gross sales (USD) | Discounts (USD) | Refunds (USD) | Net sales (USD) |
|---|---|---|---|---|
| Storage | 200,000 | 10,000 | 20,000 | 170,000 |
| Lighting | 150,000 | 5,000 | 15,000 | 130,000 |
| Total | 350,000 | 15,000 | 35,000 | 300,000 |
Storage net sales are $200,000 − $10,000 − $20,000 = $170,000. Lighting follows the same calculation. Next reconcile the cost side:
| Product | Cost of shipped goods (USD) | Returned inventory cost recovered (USD) | Net COGS (USD) | Gross profit (USD) | Gross margin |
|---|---|---|---|---|---|
| Storage | 100,000 | 8,000 | 92,000 | 78,000 | 45.88% |
| Lighting | 90,000 | 9,000 | 81,000 | 49,000 | 37.69% |
| Total | 190,000 | 17,000 | 173,000 | 127,000 | 42.33% |
Recovered cost is the carrying cost restored to inventory, not the selling price refunded to the customer. This example assumes accepted returns are resalable at that carrying cost. Damaged returns require the actual approved valuation and any related cost adjustment under the company's policy.
The company margin is $127,000 / $300,000 = 42.33%. Percentages are rounded to two decimal places after the dollar calculations. Total revenue and COGS, rather than an average of the two percentages, determine that result.
These identities must hold:
350000 - 15000 - 35000 = 300000
190000 - 17000 = 173000
300000 - 173000 = 127000
The first result must equal the ledger's net sales for the included products and period. The second must equal the corresponding COGS after return reversals. Investigate timing differences, unmatched product codes and allowance entries before interpreting the last line.
Keep an exception list for unmatched returns. A customer refund does not prove that goods reached the warehouse, and a warehouse receipt does not prove that a refund was posted. Both sides need their own evidence.
For recurring review, a gross margin dashboard should preserve these definitions and reconciliation checks. A percentage without its net sales and cost totals is hard to challenge.
Suppose Storage doubles its net sales and matched COGS while Lighting is unchanged. Each product retains the same margin:
| Product | Net sales (USD) | Net COGS (USD) | Gross profit (USD) |
|---|---|---|---|
| Storage | 340,000 | 184,000 | 156,000 |
| Lighting | 130,000 | 81,000 | 49,000 |
| Total | 470,000 | 265,000 | 205,000 |
Total margin becomes $205,000 / $470,000 = 43.62%, up 1.28 percentage points using unrounded calculations. No product's economics improved. The higher-margin product simply became a larger part of sales. Use estimated gross margin to carry those product assumptions into the next sales plan.
Bring your order, refund and product cost files to Covirage. Covirage maps the columns, and its tools compute and check net sales, matched costs and product margins; the external AI model explains the results with every figure traced to its rows. Create a free Covirage account and bring a sample of your own data.
See customer profitability for the wider commercial question behind product and channel margins.
In the example here, advertising is an operating expense below gross profit. Gross margin therefore does not show what remains after customer acquisition spending. Keep the cost classification consistent with your company's reporting policy and use a separate measure for all-cost profitability.
Returns reduce net sales, while usable merchandise returned to inventory can also reduce cost of goods sold. The refund and inventory reversal are different amounts. Damaged or missing goods may provide little cost recovery even when the customer receives a full refund.
Follow the company's documented accounting and management-reporting boundary. If marketplace fees sit below cost of sales, show them in a separate contribution calculation. Do not move fees between categories to make channels look comparable without showing the reconciliation.
There is no single useful threshold across product categories and cost policies. Compare your own products and periods on a consistent basis, then check whether gross profit covers the operating costs and profit requirement in the business plan.