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:
- Take the value of your inventory at the start of the period.
- Add the cost of the purchases you made during the period.
- Subtract the value of the inventory left at the end.
- The result is your COGS.
- 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:
| Term | What it covers | Examples |
|---|---|---|
| Cost of goods sold | Direct production cost of the goods you sold | Materials, direct labour, inbound freight |
| Operating expenses | The cost of running the business | Rent, admin salaries, marketing |
| Cost of revenue | COGS plus other costs tied to sales | SaaS 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.
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.


