Skip to content
All guides
Basics

Cost of goods sold (COGS) for ecommerce: what to include and how to calculate it

COGS is the direct cost of the products you sold. See the formula, what belongs in it for an online store, a worked example and how it links to margin and turnover.

Stokrio Team · · 6 min read

Cost of goods sold, or COGS, is what it cost you to acquire or make the products you sold in a period. It sits between sales and gross profit, and it is the number behind margin, turnover and most inventory reports. Get it wrong and every ratio built on it is wrong too.

Key takeaways

  • COGS = opening inventory + purchases − closing inventory.
  • Include landed cost: product, freight in, duty and direct handling to get it to sale-ready.
  • Exclude marketing, shipping to customers and general overhead.
  • Your valuation method (FIFO or weighted average) changes COGS when costs move. Check with your accountant.

The formula

COGS = opening inventory + purchases in the period − closing inventory

Example: opening inventory $140,000, purchases $640,000 and closing inventory $180,000 gives COGS of $600,000.

What to include

  • The supplier price of the goods sold.
  • Inbound freight, customs duty and import fees.
  • Direct labour and materials, if you make the product.
  • Packaging that is part of the product.

What to leave out

  • Advertising and marketing.
  • Outbound shipping to customers (usually a selling expense).
  • Payment processing fees (usually separate).
  • Rent and salaries not directly tied to production, unless your accountant says otherwise.

Rules differ by country and by what you report to tax authorities, so confirm treatment with your accountant.

Landed cost per unit

Spreading freight and duty across the units in a shipment gives a landed cost per unit. A product that costs $8 from the supplier but $1.60 to import costs $9.60, and that is the number margin should use. Ignoring landed costs makes imported products look more profitable than they are.

Why it matters

  • Gross margin = (net sales − COGS) ÷ net sales.
  • Inventory turnover = COGS ÷ average inventory. See the turnover calculator.
  • GMROI = gross margin ÷ average inventory. See the GMROI calculator.
  • Pricing and reorder decisions depend on true unit cost.

Valuation method

How you value remaining stock decides which costs flow into COGS. See inventory valuation: FIFO, LIFO and weighted average.

How Stokrio helps

Stokrio holds supplier costs on products, records receipts through purchase orders, costs production batches with materials, labour, overhead and scrap, and includes inventory value and turnover and GMROI in its reports. See inventory reports and production work orders.

Frequently asked questions

Is shipping to customers part of COGS?
Usually not; outbound shipping is typically treated as a selling cost. Freight to bring goods to you is part of landed cost and goes in COGS. Confirm with your accountant.
How do I calculate COGS for a Shopify store?
Take opening inventory value, add purchases at landed cost, subtract closing inventory value. Make sure every product has a cost recorded.
Does COGS include storage costs?
Warehouse costs of holding finished goods are usually operating costs, not COGS. Costs of getting goods ready to sell, such as inbound freight, are included.

Shopify App · 3PL Partner API · US$39/mo entry plan

See Stokrio with your own data

Install Stokrio from Shopify and your products and orders flow in. Running a 3PL? Start with the demo.