How to Calculate COGS for E-commerce: The Right Way
Most e-commerce brands get COGS wrong, and it costs them when it comes to pricing, profitability, and tax time. Here's how to calculate it correctly.
Anand Murugan
Founder & CEO
March 14, 2026
9 min read
Cost of Goods Sold (COGS) is the single most important number on your P&L, and it's the one e-commerce brands most consistently get wrong. When COGS is wrong, your gross margin is wrong. When your gross margin is wrong, every decision you make about pricing, ad spend, and inventory is based on bad data.
Here's how to calculate it correctly.
What COGS Actually Includes (and Doesn't)
COGS is the direct cost of producing or acquiring the products you sold during a period. For e-commerce, that typically includes:
- Product cost, what you paid your supplier or manufacturer per unit
- Inbound shipping, freight from your supplier to your warehouse or Amazon FBA
- Import duties and customs fees
- Packaging materials, boxes, poly bags, inserts that ship with the product
- FBA prep costs, if you pay a prep center to label and box inventory
COGS does not include:
- Platform fees (Amazon referral fees, Shopify transaction fees), these are selling expenses
- Outbound shipping to customers, this is a fulfillment expense
- Advertising, this is a marketing expense
- Your own labor for general operations
The line between COGS and operating expenses matters for gross margin calculation. Keep them separate.
The COGS Formula
The standard formula is straightforward:
COGS = Beginning Inventory + Purchases During Period − Ending Inventory
In practice this means: whatever inventory you started with, plus what you bought, minus what you still have at the end = what you sold (at cost).
Landed Cost: The Number That Actually Matters
The mistake most sellers make is using only the product cost from their supplier invoice. That ignores all the costs to get the product to your warehouse, and those costs are often significant.
Landed cost is the total cost per unit, including everything to get it to your fulfillment location:
Landed Cost = Product Cost + Inbound Freight + Import Duties + Inspection Fees + Prep Costs
For a product that costs $8 from your supplier, here's what the landed cost might actually look like:
- Supplier cost: $8.00
- Inbound freight (sea): $0.60/unit
- Import duty (10%): $0.80
- Customs brokerage: $0.15
- FBA prep: $0.40
- Total landed cost: $9.95/unit
If you're calculating margin based on $8, you're off by nearly 25% before you've sold a single unit.
Handling Returns
Returns need to be reversed in your COGS calculation. When a customer returns a product, you've either returned it to sellable inventory (in which case COGS should be reversed) or written it off as damaged/unsellable (in which case it's a loss).
Track return disposition carefully, Amazon's return reports tell you whether items were returned to your inventory, disposed of, or classified as defective. Each has a different accounting treatment.
Inventory Valuation Methods
The method you use to value inventory affects your COGS calculation, especially when your supplier costs change over time.
FIFO (First In, First Out), assumes you sell oldest inventory first. Most common for physical products. COGS is based on the cost of your oldest units.
Weighted Average Cost, uses the average cost of all units in inventory. Simpler to maintain and smooths out cost fluctuations. Good for high-volume sellers with frequent restocks.
Pick one method and be consistent. Switching methods mid-year affects your COGS and requires an accounting adjustment.
COGS for FBA Sellers: A Special Case
For Amazon FBA sellers, the timing question matters: do you record COGS when you ship inventory to Amazon, or when it sells?
The correct answer is when it sells. When you ship to FBA, you're transferring inventory from your warehouse to Amazon's, it's still your inventory, just in a different location. COGS is only recognized when a sale actually occurs. Shipping to FBA is an inventory movement, not a sale.
Why Getting COGS Right Matters
With accurate COGS, you can calculate true gross margin by SKU, by channel, and by period. That means you can answer questions like: Which products are actually profitable after platform fees and shipping? Which channels have better contribution margins? What's the real impact of a 10% supplier price increase?
Without accurate COGS, you're making pricing and inventory decisions in the dark.
Ready to get your books sorted?
Book a free 30-minute discovery call. We'll look at your setup and show you exactly what clean books look like for your business.
Book a Free Demo →