Cost of goods sold (COGS) is the cost assigned to the goods a business sold during a period. For a product business, it connects inventory cost to the revenue recognized from selling those goods. A common inventory-based structure is:
Cost of goods sold- What is COGS? Define the cost boundary before using the number
- The mental model
- What often belongs in product cost
- Costs that should not be casually mixed into COGS
- Shopify's product cost is not automatically your accounting COGS
- Inventory costing changes which dollars become COGS
- Returns and refunds complicate the picture
- COGS versus operating expenses
- Why COGS definitions matter for ecommerce decisions
- The formula
- Worked example
- Common mistakes
- Cost of goods sold checklist
- Questions we get asked
- OnVoard's take
What is COGS? Define the cost boundary before using the number
The exact costs included depend on the accounting framework, business model, and costing method. U.S. IRS guidance for businesses with inventory, for example, describes COGS using beginning inventory, purchases, labor, materials and supplies, other allocable costs, and ending inventory. It also distinguishes these inventory/product costs from selling expenses.
For ecommerce operators, the key lesson is not to memorize one universal checklist. It is to define the cost boundary consistently before using COGS to calculate gross profit or margin.
The mental model: attach product costs to the units that were sold
Suppose you buy 100 units for resale at $12 each. During the month you sell 60 and still hold 40. Ignoring other allocable costs for the moment:
- inventory acquired = $1,200
- ending inventory = $480
- COGS = $720
You do not normally treat the full $1,200 purchase as COGS for that month merely because cash left the bank. 40 units remain inventory rather than cost of the units sold. This is why COGS is not the same as "what we spent on products this month."
What often belongs in product cost
For a reseller, the cost base commonly starts with the cost to acquire the merchandise. Depending on the applicable accounting treatment, costs necessary to bring inventory to its condition/location can also matter. IRS Publication 334, for example, discusses freight-in and other direct/allocable inventory costs in the U.S. tax context. For a manufacturer, the calculation can also include direct materials and labor and may allocate certain production overheads.
The important editorial boundary is that COGS is a product/inventory cost concept, not a bucket for every variable business expense.
Costs that should not be casually mixed into COGS
Ecommerce dashboards often tempt operators to put every order-related cost into one number. That can make a useful unit-economics metric, but it may no longer be conventional COGS. Be explicit about items such as:
- outbound fulfillment postage
- pick-and-pack fees
- payment-processing fees
- marketplace commissions
- advertising spend
- customer-service labor
- returns processing
- warehousing
- software fees
Some of these may be classified differently under different accounting policies and business circumstances. Marketing spend, for example, is not normally a product cost simply because it helped generate the sale.
If you want a contribution-profit metric that subtracts additional variable costs, define and name it separately rather than silently expanding COGS.
Shopify's product cost is not automatically your accounting COGS
Shopify lets merchants maintain a cost per item for products and uses cost data in profit reporting. Its documentation describes gross profit and margin using net sales and cost, while noting the product cost field itself is distinct from other costs such as taxes or shipping.
That is operationally useful, but a commerce-platform product-cost field should not be assumed to reproduce the business's complete accounting COGS policy. Your accountant or ERP may include landed costs, production allocations, or costing methods that the storefront does not know. A product dashboard and financial statements can therefore disagree without either being "broken."
Inventory costing changes which dollars become COGS
When purchase costs change over time, the business needs a costing method to determine what cost is assigned to units sold and what remains in inventory. The permitted methods and tax/accounting consequences depend on jurisdiction and accounting framework.
For an editorial glossary, the important point is conceptual: 2 merchants can sell the same physical unit at the same price and report different COGS in a period because their inventory cost layers and approved accounting methods differ. Do not infer accounting fraud or analytics error from the number alone.
Returns and refunds complicate the picture
A refunded order can reverse revenue, return inventory, create write-downs, or incur nonrecoverable fulfillment/processing costs. The treatment depends on what physically happens to the product and how the accounting system records it. For operational ecommerce analysis, separate questions:
- Was revenue refunded?
- Was the product returned to sellable inventory?
- Was its inventory cost restored?
- Were additional return costs incurred?
A simple storefront report may not answer all 4.
COGS versus operating expenses
A compact income-statement mental model is: Revenue - COGS = gross profit Then operating expenses are deducted later to move toward operating profit. This distinction lets gross margin answer a product-economics question before rent, corporate payroll, marketing, and many other operating costs are layered in.
The exact presentation can differ by business and accounting standards, but the conceptual separation is useful because it prevents every cost problem from being mislabeled a margin problem.
Why COGS definitions matter for ecommerce decisions
If COGS is understated:
- gross margin looks too high
- discount headroom looks larger than it is
- products may appear more profitable than they are
If COGS is inconsistently defined across products:
- category comparisons become misleading
- bundle economics become hard to trust
- automated pricing rules can make poor decisions
If broader variable costs are silently mixed into COGS:
- finance and marketing teams can argue over "margin" while calculating different things
A written metric definition is therefore as important as the formula.
The formula
**Beginning inventory + purchases/production costs - ending inventory = COGS**Worked example
A merchant sells a jacket for $100.
Assume:- supplier product cost: $40
- inbound freight allocated to the jacket: $3
- outbound shipping paid by merchant: $8
- payment fee: $3
- advertising allocation for the order: $18
- If the merchant's COGS policy includes the supplier cost and allocated inbound freight, product COGS for this unit is $43
- Gross profit = $100 - $43 = $57
- That does not mean the order generated $57 of final profit. If the merchant separately subtracts outbound shipping, payment fee, and attributed advertising:
- $57 - $8 - $3 - $18 = $28
The $28 is a broader contribution-style view under those assumptions, not the same metric as gross profit. Keeping these layers separate tells the operator where economics are changing.
Common mistakes
- Unsold units remain inventory rather than automatically becoming cost of goods sold
- That may be useful for a contribution metric, but it changes the meaning of COGS
- It is an input to platform reporting, not necessarily the full inventory-cost model
- 2 reports can use different product-cost scopes
- A refund and a physical return are related but not identical events
Cost of goods sold checklist
- For internal analytics, document:
- the accounting/reporting purpose of the metric
- whether cost is purchase cost, landed cost (purchase cost plus inbound costs allocated to bringing inventory to saleable condition), or another approved basis
- how inbound freight/duties are handled
- how manufacturing labor/overhead is treated if relevant
- inventory costing method
- currency conversion method
- treatment of returns/damaged goods
- which costs are explicitly excluded
- source system and refresh timing
- This makes the number reproducible
Questions we get asked
Is shipping part of COGS?
It depends what shipping you mean and the applicable accounting policy. Costs to acquire/bring inventory in can be treated differently from outbound delivery to the customer. Do not use one blanket "shipping" rule.
Are payment fees COGS?
They are commonly analyzed outside product COGS, although a business may subtract them in a broader contribution-margin calculation. Name the metric clearly.
Does COGS include labor?
For manufacturers, direct labor and allocable production costs can be relevant. For a reseller, the product-cost structure differs. Applicable accounting rules determine the proper treatment.
Why does Shopify gross margin differ from my accountant's margin?
Possible causes include different product costs, refund timing, net-sales definitions, missing cost data, landed-cost treatment, inventory costing, and other accounting adjustments. Reconcile definitions before assuming one side is wrong.
OnVoard's take
For ecommerce analytics, the most dangerous COGS mistake is not an arithmetic error. It is changing the boundary without changing the label. Define product cost once, document exclusions, and keep broader contribution economics as a separate layer. That makes gross margin, pricing, discounts, and campaign profitability much easier to reason about.
Every app on every plan. Connect your store and switch on the flows in an evening.