Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

What Is Cost of Goods Sold (COGS)? The Formula and What Counts

Cost of goods sold (COGS) is the direct cost of producing the products your business sold in a period: the materials and labour that went into them. You work it out as beginning inventory plus purchases, minus ending inventory.

Shopify says COGS is also called cost of sales. It covers the costs tied directly to production, and it's the figure you take away from revenue to get gross profit. That's why it matters so much: get COGS wrong and every margin figure built on it will be wrong too.

The COGS formula

Shopify writes it like this:

COGS = (beginning inventory + purchases) - ending inventory

The logic is simple. Start with what you had in stock, add what you bought, and whatever's no longer on the shelf at the end of the period is what you sold, valued at what it cost you. Shopify's method follows the same order:

  1. Take the value of your inventory at the start of the period.
  2. Add the cost of the purchases you made during the period.
  3. Subtract the value of the inventory left at the end.
  4. The result is your COGS.
  5. Take COGS away from revenue and you have gross profit.

What goes into COGS

Shopify's list of what belongs in it:

  • Parts used to build or assemble products
  • Raw materials
  • Items bought for resale
  • Parts or machines needed to create the product
  • Supplies used in production
  • The people who put products together and ship parts
  • Shipping parts and equipment to your warehouse, including containers, freight and fuel surcharges

Shopify's fashion boutique example makes the line easy to see. Rent, utilities and marketing have to be paid however many items sell. The sewing, thread, hanger, tags and packaging for each shirt only happen because a shirt was sold, so those belong in COGS and the rest doesn't.

COGS vs operating expenses vs cost of revenue

These three get mixed up all the time, and they don't mean the same thing:

TermWhat it coversExamples
Cost of goods soldDirect production cost of the goods you soldMaterials, direct labour, inbound freight
Operating expensesThe cost of running the businessRent, admin salaries, marketing
Cost of revenueCOGS plus other costs tied to salesSaaS hosting, order fulfilment

Shopify treats COGS as variable, because it moves with how much you produce, and operating expenses as fixed, the indirect cost of keeping the doors open. Revenue minus COGS gives you gross profit; take operating expenses off that and you have operating profit. I walk through the next step down in gross profit vs net profit, and operating expenses get their own explainer in this series.

Cost of revenue is the wider term. Shopify says it includes COGS plus other costs tied to generating sales, such as order fulfilment, and it suits businesses that don't sell physical goods. A SaaS company has no goods to count, so its server hosting and the related salaries go into cost of revenue instead. That's why the same line on two companies' accounts can hold very different things.

Work with me

Want AI doing the heavy lifting in your marketing?

I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.

Why your inventory method changes the number

Shopify notes that retailers value inventory with different costing methods:

  • FIFO (first in, first out)
  • LIFO (last in, first out)
  • Weighted average cost

The method you use affects your reported profit and your tax liability, because it changes the cost assigned to the items you sold. Shopify also says tracking COGS helps you set competitive prices, manage inventory and reduce taxable income by deducting production-related expenses. Tax rules vary, so check with an accountant before you choose a method or switch to another one.

If you need a layout to put COGS in, my profit and loss statement template has it in the right place, straight under revenue and above gross profit.

My take on COGS

Keep COGS clean. The moment marketing, rent or admin salaries creep into it, your gross margin starts lying to you, and you'll set prices on a number that isn't real. Count only what went into the products you sold, pick one inventory method and stick with it, and recheck the figure every period.

Frequently asked questions

What is the formula for cost of goods sold?

Shopify's formula is (beginning inventory + purchases) - ending inventory = COGS.

What is included in COGS?

Direct production costs: raw materials, parts, items bought for resale, production supplies, the labour that assembles products and the freight that brings parts to your warehouse.

Is marketing part of COGS?

No. Shopify classes marketing, rent and administrative salaries as operating expenses, the indirect cost of running the business.

What's the difference between COGS and cost of revenue?

Cost of revenue is COGS plus other costs tied to sales, such as fulfilment. A SaaS company uses cost of revenue because it has no goods, so its hosting costs go there.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.