eMerchantBooks

July 29, 2026 · 11 min read

COGS Formula for Ecommerce: Calculate It Right (With Examples)

Calculator and cash on a desk while working through the COGS formula for an ecommerce product line

The COGS formula is: beginning inventory + purchases during the period − ending inventory = cost of goods sold. That's the whole thing. What you paid for the units you actually sold this period, no more, no less. The formula takes ten seconds to learn; the reasons seller margins are still wrong live in the three inputs, so this guide works through each one with real numbers, including landed cost, tariffs, and the per-SKU math that tells you whether a product deserves to exist.

Why the formula exists at all

Because what you bought this period and what you sold this period are different things. Buy $60,000 of inventory in March and sell a third of it, and your March cost isn't $60,000; it's the cost of the units that went out the door. The rest is an asset sitting on your balance sheet, waiting.

The formula backs into that number by counting what's left. Start with what you had, add what you bought, subtract what remains: whatever's missing must have been sold (or lost, more on that later). This is the matching principle doing its job: revenue from a unit and the cost of that unit land in the same month, so your margin means something. Break the matching and every monthly P&L you produce is fiction; buy-month profits crater, sell-month profits soar, and neither is true.

Worked example 1: a quarter of FBA sales

A seller runs one product line. On April 1, inventory on hand cost $42,000. During Q2 they received two POs totaling $55,000 in landed inventory. On June 30, a count (well, FBA inventory reports plus the 3PL's numbers) shows $38,500 of inventory remaining at cost.

InputAmount
Beginning inventory (Apr 1)$42,000
+ Purchases (landed, received in Q2)$55,000
− Ending inventory (Jun 30)$38,500
= COGS for Q2$58,500

Against $150,000 of gross Q2 sales, that's a 39% product cost, a 61% gross margin before fees and ads. Notice what made the calculation possible: a real beginning number, purchases recorded at landed cost when received (not when paid for), and an actual ending count. Miss any one and the output is a guess wearing a percent sign.

Landed cost: what belongs in "purchases"

The most common ecommerce COGS error isn't the formula, it's feeding it factory price alone. Your true unit cost is landed cost: everything it took to get the unit to sellable condition at your warehouse or the FBA dock.

  • Factory/supplier price (after any volume discounts actually received)
  • Inbound freight: ocean or air, port fees, drayage, and inbound placement or freight to FBA
  • Duties and tariffs: at 2026 tariff levels on Chinese goods this is often the second-largest component, not a rounding error
  • Customs brokerage and inspection fees
  • Prep and packaging: polybagging, labeling, kitting, inserts that ship with the product

What stays out: selling fees, storage fees, outbound shipping to customers, and advertising. Those are real costs, but they're selling expenses, not product cost; mixing them into COGS makes your gross margin useless as a product-pricing signal. (Where each belongs in your ledger is exactly what our ecommerce chart of accounts lays out account by account.)

Worked example 2: landed cost with a tariff, down to per-SKU margin

You order 2,000 units of a kitchen gadget at $6.50 FOB. Ocean freight and drayage run $2,400. The goods carry a 30% combined tariff rate, applied to the $13,000 customs value: $3,900. Brokerage is $250, and FBA prep adds $0.35 a unit ($700).

ComponentTotalPer unit
Factory cost (2,000 × $6.50)$13,000$6.50
Freight + drayage$2,400$1.20
Tariff (30% of customs value)$3,900$1.95
Brokerage$250$0.13
Prep$700$0.35
Landed cost$20,250$10.13

The "$6.50 product" costs $10.13, a 56% difference. Now finish the job, because landed cost is only half of per-SKU truth. Selling at $29.99 on Amazon: referral fee $4.50 (15%), FBA fulfillment $6.10, and say $2.40 of ad spend per unit sold. Contribution: $29.99 − $10.13 − $4.50 − $6.10 − $2.40 = $6.86 a unit, about 23% of price. The seller who prices off the $6.50 thinks they're making $19 a unit and can't figure out where the bank balance went. Run this table for every SKU quarterly; it's the single highest-value spreadsheet in ecommerce, and it's the margin math behind our money leak checklist.

Tariff note: tariffs are part of inventory cost, capitalized and expensed as units sell, not a lump expense in the month the container lands. Expensing a $3,900 tariff hit in receipt month understates that month's profit and overstates the next several. At current tariff rates this error is big enough to distort quarterly results all by itself, and it's one of the first adjustments a quality of earnings analyst makes when a buyer looks at your books.

Periodic vs perpetual: two ways to run the formula

Periodic is the formula as written: count inventory at period end, back into COGS. It's simple and it's what most sellers under a few million in revenue actually run, with "counts" assembled from FBA inventory reports, 3PL records and a warehouse walk. Its weakness: COGS only exists when you count, and everything missing gets labeled "sold," including what was actually lost or stolen.

Perpetual updates inventory and COGS on every sale: each order posts revenue and simultaneously moves that unit's cost from inventory to COGS. This is what inventory software (Cin7, Finale) or a well-configured A2X-plus-costs setup approximates. You get real-time margins and month-end closes without a full count, and physical counts become a verification step that surfaces shrinkage as its own line instead of hiding it in COGS.

Practical guidance: run periodic honestly (monthly, from reports, consistently) until SKU count and channel count make it painful, then graduate. A monthly periodic calculation done well beats a perpetual system fed garbage costs. What you can't do is neither, which is the December-only-count regime most DIY files are secretly running; it produces one true COGS number a year and eleven months of noise. A real monthly close does this arithmetic every month, which is most of the reason monthly financials from a specialist are believable and year-end reconstructions aren't.

FIFO, weighted average, and why your costs need a method

When you buy the same SKU at different prices (and with tariffs moving, you do), which cost leaves inventory when a unit sells? FIFO assumes oldest units sell first, so current inventory carries recent costs. Weighted average blends all purchases into one per-unit cost that updates with each receipt; it's what most inventory software defaults to and it smooths out purchase-price swings. LIFO exists, requires IRS commitment, and almost no ecommerce seller should touch it. Pick one, use it consistently, and don't switch because this quarter's answer looks better; consistency is half of what makes the number auditable.

A quick illustration of why it matters: you hold 500 units bought at $9.40 and receive 1,000 more at $11.20 after a tariff bump. Sell 800 units this month. FIFO charges $7,760 to COGS (500 at $9.40, 300 at $11.20); weighted average charges $8,480 (800 at the blended $10.60). Same units, same cash spent, a $720 difference in this month's reported profit, all of it timing. Neither is wrong. Flip-flopping between them is.

One bookkeeping housekeeping rule ties the whole formula together: this period's beginning inventory must equal last period's ending inventory, always. If someone "adjusts" an opening balance to make a month look right, every COGS number after it inherits the lie. When beginning and ending don't chain cleanly across months, that's the first thing to fix, and it's usually the fingerprint of books kept on a cash basis being massaged toward accrual once a year.

The errors that wreck seller COGS

  • Expensing inventory when purchased. The big one. Cash-basis "COGS" makes buy months look terrible and sell months look great, and it's the first thing lenders and buyers reject. Purchases go to the balance sheet; the formula moves them to COGS as units sell.
  • Factory price as unit cost. As example 2 showed, that's a 30 to 60% understatement of true cost in the tariff era.
  • Ignoring returns. A resellable return goes back into inventory at cost, reversing its COGS. A destroyed return stays in COGS (and belongs in your margin math as a defect cost). Netting refunds against revenue while leaving COGS alone double-hits your margin.
  • Amazon reimbursements booked as revenue. When Amazon loses your inventory and pays you, that offsets inventory at cost; booking it as sales overstates revenue and leaves ghost units in your counts. One of the nine classics in our Amazon bookkeeping problems guide.
  • Shrinkage hiding inside COGS. Under periodic, lost and stolen units silently inflate COGS. Break shrinkage into its own account when counts reveal it; a 2% shrink trend is an operations problem you can't fix if you can't see it.
  • Samples and giveaways left in inventory. Units pulled for influencers, photos or personal use come out of inventory at cost, to marketing or draws, not COGS. (They can also trigger use tax; see our Florida guide for how states treat withdrawn inventory.)

The monthly COGS entry, step by step

Here's the actual mechanical routine, for the periodic method most sellers run. Once a month, after the channels are reconciled:

  • 1. Value ending inventory. Pull FBA inventory (units by SKU) from Seller Central, your 3PL's stock report, and your own warehouse count. Multiply units by landed cost per SKU. Say it totals $71,200.
  • 2. Check the inventory account's book balance. Beginning balance plus the month's capitalized purchases. Say the books show $79,300.
  • 3. Post the adjustment. The $8,100 difference is what left inventory: debit COGS $8,100, credit Inventory $8,100. If counts show some of it wasn't sold but lost, split the debit between COGS and shrinkage.
  • 4. Sanity-check the margin. COGS divided by the month's gross sales should sit near your expected blended product cost. A month that swings from 38% to 51% with no pricing change means a missed PO, a bad count, or units valued at factory instead of landed cost. Investigate before closing, not at year end.

Fifteen minutes with good inputs. The inputs are the job: per-SKU landed costs maintained as containers arrive, and purchases capitalized instead of expensed. That routine, run every month without fail, is a core piece of our monthly close, and it's why our clients' margin trends are worth reading.

COGS for resellers: sourcing without invoices

Thrift, arbitrage and liquidation sellers run the same formula with a messier "purchases" input: garage-sale cash buys, estate lots, pallets bought sight unseen. The rules don't change, but the discipline does. Every sourcing trip needs a record (date, place, amount, what was bought), cash withdrawals need to map to purchases, and lot buys need a cost allocation across the units that came out of the pallet, usually in proportion to expected resale value. A $400 pallet that yields 30 sellable units at wildly different price points shouldn't carry $13.33 per unit; allocate by value and your per-item margins stop lying. The full tax picture for that business model is in our reseller taxes guide, and it's the daily bread of our reseller bookkeeping service.

COGS formula FAQ

Is COGS an expense? Functionally yes: it reduces income on the P&L. It's presented as its own section above operating expenses because gross profit (revenue minus COGS) is the number that tells you whether the products themselves work before overhead enters the picture.

Does COGS include shipping? Inbound shipping (freight to you or to FBA), yes, it's part of landed cost. Outbound shipping to customers, no, that's a fulfillment expense. The direction of the truck decides.

Are Amazon fees part of COGS? No. Referral and FBA fees are selling expenses. Some sellers track a separate "cost per unit sold including fees" for pricing decisions, which is useful management math, but keep it out of the COGS line in your books.

Can COGS be higher than revenue? Yes, and it means you sold below cost: liquidation, clearance, or a pricing mistake. A month of negative gross margin on a SKU is information; a year of it unnoticed is a bookkeeping failure.

What's a good gross margin for ecommerce? After true landed COGS: private-label DTC brands typically want 65% or better, marketplace-first brands often run 40% to 60%, and resale and arbitrage models live lower and win on turns. If your "gross margin" is 80%, check whether freight and tariffs actually made it into your unit costs before celebrating.

COGS and your taxes

COGS is a deduction against revenue, which makes it the largest single number on most sellers' returns and the one the IRS expects you to support with inventory records. Inflating it by deducting unsold inventory purchases is both wrong and self-defeating (you're borrowing next year's deduction, badly). The Schedule C and 1120 both walk through the formula explicitly: beginning inventory, purchases, ending inventory. If your books already run the formula monthly, tax season is copying numbers; the wider tax picture for marketplace sellers is in our Amazon seller taxes guide.

Getting the machinery built

Everything above is arithmetic once three pieces of machinery exist: purchases recorded at landed cost, an inventory asset account that's reconciled to reality monthly (with QuickBooks configured to support it), and a consistent costing method. Building that machinery, then running it every month, is the core of what we do; it's included in every plan on our rate card. If you'd like to know whether your current COGS number is close to true, the free Ecommerce Books Teardown answers exactly that, with your own numbers; request one here.

Want this handled for you?

Exit-grade books for $100K+/mo brands in your own QuickBooks, Xero or NetSuite, closed by day 10, guaranteed. Start with the $2,500 Diligence Readiness Assessment.

  • ✓ Books closed by day 10, guaranteed in writing
  • ✓ Everything stays in your QuickBooks, Xero or NetSuite file
  • ✓ Published pricing, month-to-month, no lock-in
Where do you sell?

No commitment. A partner replies within one business day.

For $100K+/mo ecommerce brands

Day-10 close guarantee · published pricing

Talk to Us