Profit & margins
How to calculate cost of goods sold (COGS)
To calculate cost of goods sold (COGS) for a period, take your inventory value at the start, add the stock you bought during the period, and subtract the inventory you have left at the end: COGS = beginning inventory + purchases − ending inventory. Every figure should be at landed cost, not retail price.
The COGS formula
COGS = Beginning inventory + Purchases − Ending inventory
- Beginning inventory
- value of stock at the start of the period, at cost
- Purchases
- landed cost of stock bought during the period
- Ending inventory
- value of stock left at the end of the period, at cost
The logic: everything you had available to sell, minus what's still on the shelf, must be what you sold.
How to calculate cost of goods sold: a worked example
Worked example: one monthExample numbers
| Input | Value at cost |
|---|---|
| Inventory at the start of the month | $80,000 |
| Stock purchased during the month (landed cost) | $30,000 |
| Inventory at the end of the month | $91,000 |
COGS = $80,000 + $30,000 − $91,000 = $19,000
With net revenue of $47,000:
- Gross profit = $47,000 − $19,000 = $28,000
- Gross margin = $28,000 ÷ $47,000 = 59.6%
You can also calculate COGS bottom-up: units sold × landed cost per unit, summed across products. Both methods should roughly agree.
A big gap points to shrinkage, miscounts or costs that aren't up to date. A stocktake usually finds the cause.
What to include in COGS for a Shopify store
| In COGS (landed cost) | Not in COGS |
|---|---|
| Supplier price per unit | Outbound shipping to customers (usually) |
| Inbound freight to your warehouse or 3PL | Ad spend and marketing |
| Import duties, customs and brokerage fees | Payment processing and marketplace fees |
| Packaging that ships with the product | Shopify plan and app subscriptions |
| Manufacturing or assembly costs | Staff, rent and other overheads |
Shopify's profit reports use the cost per item you enter on each product. Enter landed cost there, not just the supplier price, and update it when a new batch costs more or less.
Contribution Margin per SKU CalculatorWhat a single SKU actually contributes after COGS, shipping, and fees.How COGS feeds your other numbers
Gross margin. Gross margin = (revenue − COGS) ÷ revenue. Understating COGS overstates your margin, and with it your break-even ROAS and pricing decisions. See the guide to gross profit margin.
Inventory turnover. Turnover = COGS ÷ average inventory, so COGS is the top half of the formula.
Inventory Turnover Rate CalculatorHow many times a year your inventory turns over, and how many days that takes.Valuation method. When purchase costs change over time, which cost goes into COGS depends on your valuation method. FIFO assigns the oldest costs first; weighted average uses a blended cost. The guide to FIFO shows how much difference it makes.
Want this handled automatically?Forecast demand and know exactly when to reorder, before you stock out or tie cash up in overstock.Try Verve AICommon COGS mistakes
- Counting purchases as COGS. Buying stock isn't an expense until it sells. A big order in one month doesn't make that month's COGS high.
- Leaving out freight and duties. Supplier price alone understates COGS.
- Valuing inventory at retail price. Beginning and ending inventory must be at cost.
- Skipping the ending count. Without an accurate count or system figure, the formula can't work. Regular cycle counts keep it reliable.
- Ignoring write-offs. Damaged or lost stock that's written off should be recorded, not left in ending inventory.
For the full cost build-up per unit, see the guide to product costing.
FAQ
What does COGS mean?
Cost of goods sold: the direct cost of the products you sold in a period. For an online store, that's the landed cost of those products: supplier price plus freight, duties and packaging.
Is shipping included in COGS?
Inbound shipping, getting stock to your warehouse, is part of landed cost and belongs in COGS. Outbound shipping to customers is usually treated as a separate fulfillment or operating cost. Pick one approach and use it consistently.
Are ads or Shopify fees part of COGS?
No. Ad spend, payment processing fees, apps and your Shopify plan are operating expenses. COGS is only the cost of the goods themselves.
What's the difference between COGS and inventory?
Inventory is the cost of stock you still hold, shown on the balance sheet. COGS is the cost of the stock that sold during the period, shown on the P&L. When a product sells, its cost moves from inventory to COGS.