How to Calculate Gross Margin (Ecommerce Examples)

gross margin formula: net sales minus true COGS.

Key takeaways

  • Gross margin = (net sales − COGS) ÷ net sales × 100. Gross profit is the same figure in dollars.
  • For ecommerce, cost of goods sold (COGS) includes inbound freight, fulfillment, and payment fees, not only product cost.
  • Leaving those costs out can overstate your gross margin by roughly 8 points.
  • Divide by net sales (revenue after discounts and returns) rather than gross sales at full price.
  • Gross margin stops at COGS. Marketing and overhead come out below it, in contribution margin and net margin.

Gross margin is the share of every sale you keep after the cost of the goods themselves. It’s the first honest read on whether a product works: before marketing, before overhead, does the item earn more than it costs to make and deliver?

The formula takes ten seconds. The part that trips up ecommerce brands is knowing what belongs in the cost side.

This guide gives you the gross margin formula, a worked ecommerce example, the cost-of-goods adjustment most stores miss, and how gross margin differs from markup.

What is gross margin?

Gross margin is the percentage of revenue left after you subtract the cost of goods sold — the direct cost of the products you sold in a period. If a store does $100,000 in net sales and those goods cost $38,000, it keeps $62,000 before any other expense.

That $62,000 is gross profit, the dollar figure. The 62% is gross margin, the same figure as a percentage of sales.

People use the two terms interchangeably, though they answer different questions. Gross profit tells you how much you made; gross margin tells you how efficiently you made it.

The percentage is the more useful of the two day to day, because it travels across products of different prices and across months of different sizes, so you can compare a $12 SKU to a $120 one on the same footing.

The gross margin formula

The formula is short, and it has a dollar form and a percentage form.

Gross margin % = (net sales − COGS) ÷ net sales × 100     ·     Gross profit = net sales − COGS

The gross margin ratio is the same thing before you multiply by 100: a 62% gross margin is a 0.62 ratio. One detail matters before you divide. Use net sales, which is revenue after discounts and returns, rather than gross sales at full list price.

If you divide by gross sales, the margin looks better than the one you bank, because the discounts you gave and the orders customers sent back are still sitting in the denominator.

A worked ecommerce example

Take a skincare brand’s month. It runs $130,000 in gross sales, gives $10,000 in discounts and refunds, and pays the costs below to source, ship, and fulfill the goods it sold:

Line Amount Notes
Net sales $120,000 $130,000 gross sales − $10,000 discounts & refunds
Product cost $34,000 What the goods cost from the supplier
Inbound freight $4,000 Getting stock to the warehouse
Payment & transaction fees $3,500 Processor and marketplace cut
Pick and pack $2,500 Fulfilling each order
True COGS $44,000 Product + freight + fees + fulfillment
Gross profit $76,000 $120,000 − $44,000
Gross margin 63.3% $76,000 ÷ $120,000 × 100

Now the trap. If that brand had counted only the $34,000 of product cost and skipped the freight, fees, and fulfillment, it would have reported gross profit of $86,000 and a gross margin of 71.7%. That eight-point gap isn’t rounding — it’s the ecommerce cost lines a textbook formula leaves out. To calculate your own gross margin:

  1. Pull net sales for the period: Start from gross sales, then take out discounts and returns.
  2. Build true COGS: Add product cost, inbound freight and duty, fulfillment, and payment or marketplace fees.
  3. Subtract: Gross profit = net sales − true COGS.
  4. Divide and multiply: Gross margin % = gross profit ÷ net sales × 100.

What counts as COGS for ecommerce

Cost of goods sold is where ecommerce diverges from the textbook, and it’s the difference between a margin you can trust and one that flatters you. COGS is the direct cost of getting a sold unit out the door, which for an online brand covers more than the price on the supplier invoice.

Product cost is only part of ecommerce COGS. Leave out freight, fulfillment, and fees and your margin looks about 8 points better than it is.

Four things belong in the cost base: the product cost itself; inbound freight and any import duty, which together make up the landed cost of a unit; the pick-and-pack or fulfillment cost of getting each order shipped; and the payment and marketplace fees taken on every sale. What stays out matters as much.

Marketing and ad spend, salaries, software, and rent are real costs, but they sit below the gross line — pulling them into COGS turns gross margin into a different metric. Get the cost base right once and every number that leans on it, from landed cost to net margin, inherits that accuracy.

Gross margin vs markup

Gross margin and markup use the same dollars of profit and measure them against a different base. Markup is profit over cost; margin is profit over price. The same product gives two very different-looking percentages.

Line Value How it’s found
Cost $16 What the unit costs you
Price $40 What you sell it for
Profit $24 Price − cost
Markup 150% $24 ÷ $16 (profit over cost)
Margin 60% $24 ÷ $40 (profit over price)

The two convert cleanly: margin = markup ÷ (1 + markup), and markup = margin ÷ (1 − margin). Mixing them up is a common pricing error, because a 50% markup sounds like a healthy 50% margin when it’s really a 33% one. When you set prices from a target margin, solve for the markup so the price lands where the margin needs it.

Where gross margin sits — and why to run it per SKU

Gross margin is the first rung on a ladder. Revenue comes in at the top; take out COGS and you reach gross margin; take out the rest of your variable costs, including shipping and ad spend, and you reach contribution margin; take out fixed costs and overhead and you land on net margin.

Each rung answers a different question, and gross margin answers the narrowest one: does the product itself pay?

Because it’s a store-wide average by default, gross margin can look healthy while individual products lose money underneath it. A 60% blended margin can hide a SKU running at 25% and another giving product away on a permanent discount.

The fix is to compute margin at the SKU level, where the drag becomes visible. A few habits keep the number useful:

  • Run it per SKU and per channel: A blended average hides the products and channels dragging you down.
  • Rebuild COGS when costs move: Supplier prices, freight, and fees drift, so re-cost on new quotes.
  • Check yours against your category: Whether 60% is strong depends on your vertical — see what a good gross margin looks like by vertical.

Run gross margin on every SKU

A store-wide gross margin is a starting point, and it hides as much as it shows. The P&L by SKU template runs revenue, true COGS, and gross margin for every product you sell, so you can see which SKUs earn their shelf space and which quietly lose money. Build your margins SKU by SKU.

Frequently asked questions

Is gross margin the same as gross profit?

No. Gross profit is a dollar amount — net sales minus COGS. Gross margin is that same figure as a percentage of net sales. Gross profit tells you how much you kept; gross margin tells you how efficiently, which makes it easier to compare across products and months.

What should be included in COGS for ecommerce?

Product cost, inbound freight and duty, fulfillment (pick and pack), and payment or marketplace fees. Those are the direct costs of getting a sold unit out the door. Marketing, salaries, software, and rent stay out of COGS — they come out below the gross line.

What's the difference between gross margin and markup?

They measure the same profit against a different base. Markup is profit divided by cost; margin is profit divided by price. A product at $16 cost and $40 price carries a 150% markup and a 60% margin. Convert with margin = markup ÷ (1 + markup).

Do you use gross or net sales for gross margin?

Net sales — revenue after discounts and returns. Dividing by gross sales at full list price overstates the margin, because the discounts you gave and the refunds you paid are still in the denominator.

What's a good gross margin for ecommerce?

Most DTC brands land between 50% and 70%, but the right target depends heavily on your category and business model. For the ranges by vertical and how to read them, see our guide to what a good gross margin looks like for ecommerce.

Share the Post:

BEST VALUE

The Full Library

All 20 templates. Every category, every model.

The Full Template Library

Every operator-grade workbook in the catalog, priced as one purchase.

20 templates · both platforms · lifetime updates + new releases

Table of Contents