Gross Margin Calculator for Ecommerce: Formula, Costs, and Examples
Calculate gross margin from net sales and cost of goods sold, then keep payment fees, fulfillment, ads, and overhead in the right layer.
Table of Contents
- Gross margin formula and a quick example
- Decide what belongs in COGS
- Net sales: choose the denominator before comparing products
- Gross margin versus markup, contribution margin, and net margin
- Worked ecommerce example beyond gross profit
- A practical monthly gross-margin workflow
- Common gross-margin mistakes
- FAQs
Gross margin (%) = (net sales − cost of goods sold) ÷ net sales × 100.
Gross profit = net sales − cost of goods sold.
Use the same sales basis and cost scope for every product and period.
A gross margin calculator is useful only after you decide what counts as net sales and cost of goods sold (COGS). For an ecommerce product, gross margin usually compares product revenue after discounts and refunds with the costs directly assigned to the goods sold. It does not automatically subtract advertising, payment processing, pick-and-pack, software, payroll, or every other business expense.
The Shopify Profit Margin Calculator now shows gross profit and gross margin from the selling-price and product-cost inputs, alongside contribution after fulfillment, payment and platform fees, and ad cost. If you need discount and shipping subsidy in the same view, use the gross margin calculator with shipping, which separates gross margin, markup and after-shipping contribution. For a discounted order, use the actual net item selling price as the input; the calculator does not have separate refund, tax, or shipping-revenue fields. Use a matching revenue basis when you compare its simple product gross-margin figure with Shopify's period reports.
For a side-by-side explanation of what belongs below gross profit, read gross margin vs. contribution margin for Shopify orders.
Gross margin formula and a quick example
Suppose an item generates $80 in net product sales after a discount and refund adjustment. If its COGS is $32, then:
- Gross profit = $80 − $32 = $48.
- Gross margin = $48 ÷ $80 × 100 = 60%.
The 60% means $0.60 of each dollar of net product sales remains after the COGS included in this calculation. It does not mean the store keeps 60 cents as final profit. Costs outside COGS still need to be paid.
The reverse calculation is also useful. If net sales are $80 and the target gross margin is 60%, the maximum COGS consistent with that target is $80 × (1 − 0.60) = $32. This is a planning ceiling under the chosen COGS definition, not a purchase order recommendation by itself.
Decide what belongs in COGS
For a physical product, COGS may include the amount paid to the supplier and costs needed to bring inventory to its saleable location and condition. Depending on the accounting policy, that can include inbound freight, duties, insurance, and production packaging. Apply one documented method across the catalog and reconcile it with the business's accounting records.
Do not count a cost twice. If landed unit cost already includes inbound shipping and duty, do not subtract those amounts again as separate COGS. If packaging is included in supplier unit cost, do not add it a second time. Keep an itemized cost build so the source and date of each estimate are visible.
Costs that are often analyzed after gross profit include:
| Cost | Common treatment in a product gross-margin view | Why to track it |
|---|---|---|
| Payment processing | Usually below gross profit | It varies with payment amount and provider terms. |
| Pick-and-pack and outbound postage | Usually below gross profit in a simple product view | These depend on fulfillment method, basket, and destination. |
| Advertising and affiliate commissions | Usually below gross profit | These are acquisition or selling costs, not the cost of the goods themselves. |
| Returns and damaged inventory | Depends on accounting policy | Returned units may be restocked, written down, or lost. |
| Payroll, rent, and software | Usually operating expenses | These support the business across many products. |
There is no universal management report layout for every store. If your accounting policy places a cost inside COGS, use that policy for financial reporting. For internal product decisions, you can also build a separate contribution view, but label it clearly rather than silently changing the definition of gross margin.
Net sales: choose the denominator before comparing products
List price is not always the revenue base that a store actually retains. A practical product-level view may begin with item sales after discounts and refunds. Decide whether customer-paid shipping is excluded or included; if it is included, include related shipping costs in the same view. Sales tax collected for remittance is generally not product revenue, but follow the accounting policy used for your reporting.
For period analysis, keep the time window consistent. Do not divide one month's gross profit by another month's sales, or compare one product's net sales with another product's pre-discount sales. For SKU-level decisions, match the sales and product costs to the same units sold and returns treatment.
Gross margin versus markup, contribution margin, and net margin
These metrics answer different questions:
- Gross margin: gross profit divided by net sales, after the defined COGS.
- Markup: the amount above cost divided by cost. If an item costs $32 and sells for $80, markup on that cost is ($80 − $32) ÷ $32 = 150%, while gross margin is 60%.
- Contribution margin: revenue less a selected set of variable costs, divided by the matching revenue base. It may include COGS plus fulfillment, processing, and other variable costs.
- Net profit margin: net profit after the business's recognized expenses divided by revenue for the same period and accounting basis.
Do not compare a product's gross margin to a company's net margin as if they were interchangeable. A product can have strong gross margin and still lose money after expensive acquisition, shipping, returns, or fixed overhead.
Worked ecommerce example beyond gross profit
Assume a product has $80 in net product sales and $32 COGS. Gross profit is $48, and gross margin is 60%. Now add illustrative order-level assumptions: $7 fulfillment, $2.62 payment fees, $0.80 platform fees, and $18 acquisition cost. These rates and costs are examples for arithmetic, not current standard fees.
Contribution after those entered costs is $48 − $7 − $2.62 − $0.80 − $18 = $19.58. As a share of $80 net sales, that is about 24.5%. The business still needs to account for any omitted return losses, customer-service cost, fixed payroll, software, and other operating expenses before calling the remainder net profit.
Use the order contribution calculator to model the extra fee, shipping, and acquisition layers it supports. Its output depends on your inputs and does not reconcile accounting statements or include costs that are not entered.
A practical monthly gross-margin workflow
- Select the reporting period and revenue basis. State how discounts, refunds, tax, and customer shipping are treated.
- Set the COGS definition and cost date. Check that landed costs are not duplicated.
- Calculate gross profit and gross margin for the whole store, then by product or SKU where source data permits.
- Compare the result with the same period's prior results and investigate changes in price, discounts, product mix, supplier cost, and returns.
- Add a contribution layer for fulfillment, fees, and acquisition costs when deciding whether a product can support a promotion or paid traffic.
- Reconcile a sample of units and orders with inventory, accounting, payment, and fulfillment records.
For a promotion, calculate margin using the discounted net price, not list price. For a bundle, assign the bundle revenue and costs consistently across included items or evaluate the bundle as its own offer. For a product with multiple variants, calculate unit costs at the variant level if the cost differences are meaningful.
Common gross-margin mistakes
- Using cost as the denominator and calling the result margin; that calculates markup.
- Treating gross margin as final profit or assuming it includes ads and processing fees.
- Comparing a discounted period with full-price sales without labeling the revenue basis.
- Excluding inbound freight from landed cost, or counting freight and duty twice.
- Using one store-wide average to make a SKU decision when product costs vary materially.
- Ignoring refunds, write-offs, or inventory cost changes while interpreting a trend.
FAQs
What is a good gross margin for an ecommerce product?
There is no single target that works for every category or acquisition model. Set a target from your landed product cost, fulfillment, return profile, acquisition plan, overhead, and pricing context. A gross-margin percentage is only one layer of the decision.
Does gross margin include shipping and payment fees?
It depends on the reporting policy. In a simple product gross-margin view, payment fees and outbound fulfillment are often tracked below gross profit. If your accounting policy includes any such item in COGS, apply it consistently and state the definition.
How is gross margin different from markup?
Gross margin divides gross profit by sales; markup divides the amount above cost by cost. If cost is $32 and sales are $80, gross margin is 60% and markup is 150%.
Can a product have high gross margin but still lose money?
Yes. Advertising, fulfillment, payment fees, refunds, and operating expenses can reduce or eliminate the amount left after COGS. Add those costs in a clearly defined contribution or profit view.