How to Calculate COGS for Ecommerce (With Examples)

ecommerce COGS breakdown from landed unit cost to gross profit.

Cost of goods sold (COGS) is the direct cost of the goods you sold in a period, and on most ecommerce P&Ls it’s the single biggest line on the page. It’s also the one operators most often guess at.

This guide shows you how to calculate COGS for an ecommerce store — the formula, what belongs in the number, the costing methods, and worked examples you can copy straight onto your own SKUs.

Get COGS right and everything downstream gets trustworthy: gross margin, your pricing floor, and what you owe at tax time. Get it wrong and all three are off by the same amount.

The math is short. The work is feeding it the right costs, and for ecommerce that means landed cost, the price on the supplier invoice plus everything it takes to land the goods in your warehouse.

What is cost of goods sold (COGS)?

Cost of goods sold is the direct cost of the products a business sold during a period — what you paid to buy or make those specific units. It sits at the top of the income statement, right under revenue, and revenue minus COGS gives you gross profit. The costs of running the business sit below that line.

COGS counts the units you sold, and only those. Stock still sitting in your warehouse is an asset on your balance sheet; it becomes COGS the moment it ships to a customer. That timing trips up a lot of new stores, and it’s the heart of the cash-versus-accrual difference we’ll come back to.

For an ecommerce brand, the phrase “direct cost” does more work than it looks. It isn’t only the factory or wholesale price. It’s the landed cost of each unit, which folds in the freight and duties that get the product to you.

What’s included in COGS, and what isn’t

COGS covers every direct cost of getting a product into your warehouse and ready to ship. It leaves out anything that happens after the sale, plus the general cost of running the business. Here’s the split for a typical ecommerce store:

In COGS Not in COGS (operating expense or cost of sale)
Product or manufacturing cost Marketing and advertising
Inbound freight to your warehouse or 3PL Outbound shipping to the customer
Import duties and tariffs Pick, pack, and fulfillment labor
Direct production or assembly labor Merchant and marketplace fees
Product packaging — boxes, inserts, labels Software, apps, rent, and overhead

The line that catches most stores is fulfillment. Freight from your supplier to your warehouse is COGS; the pick, pack, and outbound shipping once an order comes in is a cost of sale that sits below gross profit.

If you run through a third-party logistics provider (3PL), split its invoice on that boundary rather than dropping the whole thing into one bucket.

This is why ecommerce COGS is built on landed cost — your unit price plus inbound freight and duties. Getting that per-unit number right is a task on its own, and our Landed Cost Calculator walks each cost in so the figure you carry into COGS holds up.

For ecommerce, “product cost” means landed cost: the unit price plus inbound freight and import duties. Leave those out and your COGS, and every margin below it, comes in too low.

The COGS formula

The formula for cost of goods sold is short:

COGS = Beginning Inventory + Purchases − Ending Inventory

Say you start the quarter holding $2,400 of inventory, buy another $5,000 during the quarter, and finish with $4,000 on the shelf. Your COGS is $2,400 + $5,000 − $4,000 = $3,400. That $3,400 is the cost of the stock that left as sales.

The ecommerce version adds one refinement: fold inbound freight into purchases and net out supplier discounts and returns, so the number reflects true landed cost. Each term is straightforward:

  1. Beginning inventory: The value of stock on hand at the start of the period, equal to last period’s ending inventory.
  2. Purchases: The inventory you bought during the period, counted at landed cost.
  3. Ending inventory: The value of stock still on hand when the period closes, usually confirmed by a physical count.

Which inventory costing method should you use?

Most ecommerce brands use weighted average cost (WAC), which spreads total inventory cost evenly across units. FIFO assumes your oldest stock sells first; LIFO assumes the newest does. The method you pick changes COGS whenever unit costs move, so choose one and hold it across the year.

Say you bought 100 units at $5, then another 100 at $8 as prices rose, and sold 120 over the period. The same 120 units sold produce three different costs:

Method How it values the units sold COGS
FIFO Oldest cost first — 100 @ $5, then 20 @ $8 $660
LIFO Newest cost first — 100 @ $8, then 20 @ $5 $900
WAC Blended $6.50 average × 120 units $780

The gap widens with the direction of your costs. When prices rise, FIFO expenses the cheaper old stock first and reports lower COGS (and higher taxable profit), while WAC lands in between.

WAC is the practical default for most stores because inventory software computes it for you. LIFO is permitted only under US tax rules and rarely fits ecommerce

For the full trade-offs and when each one earns its place, we go deeper on FIFO, LIFO and WAC in the costing-methods guide.

How do you calculate COGS for a single product?

For one product, COGS is its landed unit cost multiplied by the units you sold: unit cost × units sold. Do that for every SKU and add them up, and you’ve built period COGS from the bottom — plus a clear read on which products carry their weight. Here’s a month across three products:

SKU Landed unit cost Units sold COGS
Grip A $6.00 400 $2,400
Grip B $9.00 250 $2,250
Grip C $4.00 600 $2,400
Total 1,250 $7,050

The catch is accuracy. Per-SKU COGS is only as good as the landed cost behind each unit, so a guessed $4 that turns out to be $5.20 once freight and duty land will quietly overstate the profit on every one of those 600 units.

When you keep unit costs current and roll them up, a model like P&L by SKU turns units sold into COGS and gross margin for each product, so the SKUs earning their shelf space are obvious.

A worked example: COGS for a full month

Let’s tie the two methods together on one store’s month. The formula method and the per-product method should land on the same number; if they don’t, something’s miscounted.

Start with the books. You hold $20,000 of inventory at the start of the month, buy $5,050 of new stock at landed cost, and finish with $18,000 on hand. The formula gives $20,000 + $5,050 − $18,000 = $7,050.

Now take the per-SKU roll-up from the table above — $2,400 + $2,250 + $2,400 — and it also comes to $7,050. Same COGS, reached two ways. The formula is faster for a whole period; the per-SKU build shows you where the cost truly sits.

How often should you calculate COGS?

Calculate COGS at least once a month, on the same schedule as your books. A monthly cadence keeps gross margin current, catches cost creep from suppliers or freight before it quietly eats a quarter, and gives you a clean figure for each period’s P&L.

Many stores tie it to the month-end close: reconcile stock counts, update landed unit costs, then run the formula. If you sell high volume or your input costs swing, a mid-month spot-check on your top SKUs is worth the few minutes.

Common COGS mistakes to avoid

Run your own number against this quick check. Each of these quietly distorts COGS, and the margin that sits beneath it:

  • Expensing stock when you buy it: Counting inventory as COGS at purchase instead of at sale overstates cost in buying months and hides it in others. That’s cash-basis timing; accrual matches the cost to the sale.
  • Leaving out freight and duty: Inbound shipping and import tariffs are part of landed cost. Drop them and COGS looks lighter than the units cost you.
  • Folding in outbound shipping or fees: Delivery to the customer, pick-and-pack, and marketplace fees belong below gross profit. Adding them inflates COGS and muddies product margin.
  • Switching methods mid-year: Moving between FIFO, LIFO, or WAC partway through a year breaks comparability. Change only at a clean year boundary.
  • Ignoring returns and discounts: Supplier credits lower your purchases, and customer returns put units back into inventory. Skip them and the number drifts over time.

Where COGS fits: gross margin, pricing, and taxes

COGS feeds almost every profit decision you make. Subtract it from revenue and you get gross profit; state that as a share of revenue and you get gross margin (revenue minus COGS, as a percentage of revenue).

It’s the first read on whether a product’s economics work. For the full walk-through, see how to calculate gross margin with worked examples, and what a good gross margin for ecommerce looks like by vertical.

COGS also sets your pricing floor. A price below landed unit cost loses money before a single other expense lands. Take out the rest of the per-order costs — shipping, fees, ad spend — and you’re into contribution margin, the profit left after everything that rises with each sale.

At tax time, COGS is deductible, so an accurate number changes your taxable profit, which is why the method and timing matter beyond your dashboards.

When it’s time to post it, the cost-of-goods-sold journal entry is its own small task. This is planning guidance, not tax advice; confirm treatment with your accountant. COGS is one line in the wider set of numbers we cover in ecommerce accounting.

See profit by product

When every product hides inside one blended COGS number, your weakest SKUs coast on the backs of your best, and you can’t tell which is which.

P&L by SKU takes the unit costs and units sold you already track and returns COGS and gross margin for each product, so the winners and the margin leaks are both in plain sight.

Drop last month’s numbers in and see where your profit comes from — get the P&L by SKU template.

Frequently asked questions

Is shipping part of COGS?

Inbound shipping is part of COGS; outbound shipping to the customer isn’t. Freight from your supplier to your warehouse counts toward landed cost, while delivery to the buyer is a cost of sale that sits below gross profit.

Does COGS include labor?

COGS includes direct labor that produces or assembles the product, such as manufacturing or kitting, but not the labor to pick, pack, and ship an order after it sells. The test is whether the work gets the product ready to sell or fulfills a sale that already happened.

Are Amazon and marketplace fees COGS?

Marketplace and payment fees aren’t COGS; they’re selling costs that sit below gross profit. They rise with each order, so they belong in contribution margin, which is why per-order profitability on a channel like Amazon can diverge sharply from gross margin.

What’s the difference between COGS and cost of sales?

COGS is the cost of acquiring or making the products you sold, while cost of sales is broader and also includes the cost of fulfilling the order — pick, pack, and outbound shipping. Some ecommerce P&Ls combine the two; if yours does, keep the split visible so you can still see product cost on its own.

How do you calculate COGS for a single product?

Multiply the product’s landed unit cost by the units sold in the period — a $6 landed cost on 400 units sold is $2,400 of COGS. Summing that across every SKU gives the same period total as the beginning-plus-purchases-minus-ending formula, built from the bottom up.

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