Cost of goods sold for ecommerce brands: the formula and what to include

Mirena Rumenova
Mirena Rumenova
December 3, 2026
Cost of goods sold for ecommerce brands: the formula and what to include

Ecommerce brands calculate product cost of goods sold (COGS) by recording the cost of inventory and recognizing the cost of units sold. For resellers, inventory cost includes the supplier price after discounts plus eligible inbound freight, duties and other acquisition costs. Reconcile opening stock, purchases and closing stock using a consistent valuation method, then attribute sold-item costs to the relevant channels.

The cost of goods sold formula fits on one line. The mistakes hide inside the purchases figure, where freight bills and duty invoices go missing.

This guide explains a simplified reseller COGS formula with a worked example, then distinguishes inventory costs from selling expenses. It draws on IAS 2 inventory guidance and IRS Publication 334 for US small-business tax context; the two are not interchangeable. Confirm the treatment for your business and jurisdiction with your accountant.

What is the cost of goods sold formula for ecommerce brands?

For a reseller, a simplified periodic-inventory formula is beginning inventory plus net purchases at landed cost, minus ending inventory. Use consistent valuation and reconcile returns, losses, write-downs and other adjustments separately. Manufacturing also requires conversion costs and a reconciliation of raw materials, work in progress and finished goods.

Written as the cost of goods sold equation:

COGS = beginning inventory + purchases at landed cost, minus ending inventory

Beginning inventory plus net purchases is the cost of goods available for sale in this simplified reseller example. Subtract closing inventory valued on the same basis. A physical count establishes quantities, not their value; reconcile other stock movements before treating the balance as COGS.

The US tax version follows the same logic. IRS Publication 334 walks small business owners through COGS on Schedule C, lines 35 to 42. Those lines cover beginning inventory, purchases, cost of labor, materials and supplies, other costs and, last, ending inventory, which is subtracted.

Brands that only resell finished goods do most of their work in the purchases line. That is where the errors start.

A worked example with two suppliers

A worked example with two suppliers shows how much landed cost changes the answer. All figures below are EXAMPLE numbers in one reporting currency, so read them as euros or dollars.

EXAMPLE: a homeware brand sells on Shopify and Amazon. Supplier A is overseas, so its goods travel by sea and pay import duty. Supplier B is domestic, so it only adds trucking.

EXAMPLE line itemSupplier A (overseas)Supplier B (domestic)Total
Beginning inventory, at landed cost20,000
Supplier invoices30,00012,00042,000
Trade discount(600)0(600)
Inbound freight2,4001,5003,900
Customs duties1,80001,800
Purchases at landed cost33,60013,50047,100
Cost of goods available for sale67,100
Ending inventory, valued at landed cost(22,100)
COGS for the period45,000

Booking supplier invoices alone would leave 5,700 of freight and duty out of purchases. That cost does not vanish. It splits between units sold and units still in stock. Both COGS and inventory come out too low, and gross margin looks better than it is.

What should be included in ecommerce COGS?

Inventory cost includes purchase costs, eligible inbound freight, import duties and other costs of bringing inventory to its present location and condition. For manufacturers, it also includes conversion costs such as direct labor and allocated production overhead. These costs become COGS when the related inventory is sold; selling costs are not capitalized into inventory.

What is cost of sales? For product businesses, cost of sales is often used as another name for COGS. However, reported cost-of-sales lines can include additional costs under the business's accounting presentation. Define product COGS, reported gross margin and contribution margin before comparing channels.

The table below summarizes inventory-cost treatment for common ecommerce items using IRS Publication 334 and the IAS 2 Inventories standard. Costs included in inventory become COGS when the goods are sold. IAS 2 excludes selling costs and administrative overheads that do not contribute to bringing inventory to its present location and condition; this does not dictate where every expense appears in an income statement.

CostInventory cost?Basis
Supplier purchase price, less trade discounts and rebatesYesIAS 2, costs of purchase
Freight-in, express-in and cartage-inYesIRS Publication 334
Import duties and non-recoverable taxesYesIAS 2, costs of purchase
Handling directly tied to bringing stock inYesIAS 2, costs of purchase
Direct materials, production labor and allocated production overheadYesIAS 2, purchase and conversion costs
Packaging integral to a manufactured productYesIRS Publication 334
Shipping boxes and mailers not integral to the productNo; generally a shipping or selling expenseIRS Publication 334
Outbound shipping to customersNo; generally a selling costIAS 2 excludes selling costs
Amazon referral fees, Shopify fees and payment feesNo; generally a selling costIAS 2 excludes selling costs
Advertising and influencer costsNo; generally a selling costIAS 2 excludes selling costs
Storage after goods are ready for saleUsually noIAS 2 excludes most storage costs
Administrative overheads unrelated to bringing inventory to its location and conditionNoIAS 2 excludes overheads not contributing to location and condition

Outbound delivery, marketplace commissions, payment-processing fees and advertising are generally selling or transaction costs rather than inventory acquisition costs. Track them separately from product COGS for operational analysis, while following your accountant's policy for income-statement presentation.

Taxes need extra care. IAS 2 counts only taxes you cannot recover, so VAT you reclaim stays out of COGS. Sales tax you collect from US shoppers is passed on to the tax authority, so it stays out as well. Confirm both treatments with your accountant.

How do I calculate COGS with shipping and storage costs?

For inventory valuation, ask whether a cost brings goods to their present location and condition. Eligible inbound freight is included; outbound delivery and post-production storage are generally not. Their presentation within reported cost of sales or operating expenses is a separate accounting-policy question.

IRS Publication 334 treats freight-in, express-in and cartage-in on merchandise bought for sale as part of COGS. Add each freight bill to the shipment it arrived with, then spread it across the units in that shipment.

Track customer-delivery costs by channel alongside product COGS. Deduct fulfillment and channel fees in a clearly labeled contribution-margin view; do not assume every business presents these costs below reported gross margin.

Under IAS 2, storage is generally excluded from inventory cost unless necessary in production before a further production stage. Post-production warehouse or 3PL storage therefore normally remains a period expense rather than inventory. Production-facility costs and US tax capitalization rules can require different treatment. Confirm both capitalization and expense presentation with your accountant.

How do you calculate COGS across multiple suppliers and channels?

Calculating COGS across multiple suppliers and channels takes five steps, from the purchase order to the channel report. The steps work the same for two suppliers or forty.

  1. Record every supplier invoice against its purchase order, net of trade discounts and rebates.
  2. Add inbound freight and customs duties to the shipment they belong to, then spread them across the units received.
  3. Pick one inventory valuation method, such as FIFO or weighted average, and use it every period.
  4. Reconcile inventory you own across warehouses, 3PLs, marketplace fulfillment centers and goods in transit. Check ownership and cut-off, exclude stock owned by others, and value quantities consistently.
  5. Split COGS by channel using the units each channel sold and their landed unit cost.

Step 2 is where multi-supplier brands lose accuracy. Spread freight by weight or by value, whichever matches how the carrier billed you. Keep the exchange rate used for foreign invoices with the purchase order.

Step 5 turns one company number into channel numbers. EXAMPLE split: using the worked example, suppose Shopify sold 60% of the units and Amazon sold 40%, all at the same average unit cost. Shopify then carries 27,000 of the 45,000 COGS and Amazon carries 18,000.

Product gross margin can look healthy while the channel's contribution after fulfillment and marketplace fees is thin. The example allocates product COGS only; compare channels using the same cost definitions and show channel fees separately in the operational view, regardless of the income statement's presentation.

How do you track manufacturing and inventory costs consistently?

Link products to their production inputs and operations, record material issues and finished-goods receipts, and reconcile the resulting inventory values. A bill of materials (BOM) is a general industry term for a component list. Prim.io uses production recipes for manufacturing; its BOM terminology refers to sale-time kits or bundles, not a manufacturing recipe.

IAS 2 includes conversion costs in inventory: direct production labor and an appropriate allocation of fixed and variable production overhead, as well as materials. These costs enter COGS when finished goods sell. Do not assume that materials-only software calculations capture every accounting cost.

In Prim.io, a production recipe defines the materials and operations for a product. Recipe cost uses current average material stock cost. Update the recipe when components or quantities change; a supplier price change alone does not mean a recipe change automatically recosts every finished unit.

Prim.io work orders show materials issued and finished quantities still to receive, with partial finished-goods receipts supported. They do not reserve components, track production stages or maintain a separate work-in-progress quantity or state. Reconcile incomplete production and any labor or overhead allocations through the appropriate accounting process.

Prim.io connects purchasing, inventory and production records within an all-in-one cloud ERP. Record supplier and eligible landed costs consistently, and use production recipes and work orders for manufacturing on an eligible plan. Inventory-cost accuracy still depends on complete entries, configuration and accounting review.

Why are my ecommerce profit margins inaccurate using spreadsheets?

Ecommerce profit margins built in spreadsheets drift because the costs that feed COGS arrive late and from different teams. Four gaps show up again and again.

  • Freight bills arrive weeks after the goods, often after some units have already sold at the old cost.
  • Customs duty invoices sit in finance and never reach the item cost in the stock sheet.
  • Production-recipe changes stay in the production file while the margin sheet keeps outdated quantities or costs.
  • Channel fees get mixed into cost lines, so COGS for Amazon and Shopify stops being comparable.

Basic webshop tools add another limit. Any cost figure typed into a webshop holds only what someone entered, usually the supplier price.

Spreadsheets and webshop cost fields can support costing when properly maintained, but disconnected files make it easier to miss landed-cost allocations, production updates or late invoices. Reconcile them to purchasing and stock records rather than assuming a manual figure stays current.

What role does BI play in analyzing your product margins?

BI can combine recorded sales and inventory costs into product and channel margin views, reducing repeated spreadsheet preparation. Results depend on complete source data, consistent cost definitions, configured reports and the reporting refresh.

Prim.io BI is powered by Qlik and reads the same order and cost data as the ERP. You can start at total gross margin and drill down to a channel, then a single SKU.

Is the wholesale price list still covering landed cost after a freight increase? Which SKUs have lower contribution on Amazon after fees than on Shopify? Use configured reports to investigate these questions, checking whether all relevant costs and the latest data are included.

How Prim.io handles COGS

Prim.io is a cloud ERP connecting sales, purchasing, inventory, warehouse operations, finance, CRM and business reporting for wholesalers, distributors and retail brands. For ecommerce teams, that shared operational record supports inventory-cost reconciliation and channel-margin analysis. Manufacturing functionality is subject to plan; statutory accounting coverage is available only in selected countries.

The Prim.io AI assistant is built into Prim.io and answers questions using the company's own sales, stock and finance data. Built-in AI also supports invoice scanning and classification, address correction and payment matching. Separately, Prim.io MCP connects compatible tools such as Claude, ChatGPT and Cursor to supported data and functions, subject to user permissions and configured approvals. Review important answers and proposed actions; AI does not replace accounting judgment.

For product COGS, record supplier prices and eligible freight and duty allocations against the relevant goods. Prim.io manufacturing uses production recipes and work orders, not BOM kits. Check material issues, finished-goods receipts and any additional accounting cost allocations before relying on finished-unit values.

Connected webshop and marketplace orders support a shared sales and stock record. Stock-quantity updates to external channels run on a schedule when quantity sync is enabled. Use BI to review recorded sales and cost data, allowing for report refreshes and late cost adjustments rather than assuming instant final margins.

Open a free demo account

Free demo account. No credit card required.

Why ecommerce brands choose Prim.io

Prim.io combines connected operations with built-in AI, CRM and business reporting. Its broader fit includes wholesalers, distributors and retail brands, not only online stores. Ecommerce teams can use channel integrations as part of that operational foundation.

  • Prim.io processes over 3.1 million orders per month.
  • 50+ native integrations connect Shopify, WooCommerce, Amazon, other marketplaces and couriers.
  • BI powered by Qlik turns orders and costs into margin reports.
  • Plans from €180 per month, billed annually, excluding VAT. See Prim.io pricing.
  • Prim.io says most companies go live in around 5–8 weeks, depending on complexity, integrations and data migration. Larger or more complex setups may take longer.

Store, marketplace and courier connectors are priced per connector (€20 to €50 per month); finance connectors are free.

Frequently asked questions about COGS

COGS questions from multi-channel brands tend to repeat. The short answers below summarize this guide.

What is the basic COGS formula?

For resellers, the simplified formula is beginning inventory plus net purchases at landed cost minus ending inventory. Reconcile returns and other adjustments, check ownership across locations and goods in transit, and use a consistent valuation method. Manufacturers must also account for conversion costs and movements in raw materials, work in progress and finished goods.

What is the difference between COGS and operating expenses?

Product COGS is the cost of inventory sold. Eligible purchase and conversion costs enter inventory first; selling and general business costs are generally period expenses. Income-statement presentation can vary, so distinguish product COGS from reported cost of sales and contribution margin, and confirm your policy with an accountant.

How does an ERP automate COGS tracking?

An ERP connects purchasing, inventory movements and sales so recorded unit costs can support COGS reporting. Automation depends on complete supplier and landed-cost entries, accurate production records where relevant, configuration and reconciliation. BI reflects the available data and its refresh, not a guarantee that every cost is final.

Is shipping included in cost of goods sold?

Eligible inbound freight forms part of inventory cost and becomes COGS when the goods sell. Outbound customer delivery is generally a selling or fulfillment cost rather than inventory cost; its income-statement presentation depends on policy. IRS Publication 334 distinguishes integral product packaging from shipping or selling packaging for its US tax context.

How much does Prim.io cost?

Prim Plus is €180, Prim Pro €540 and Prim Enterprise €1,710 per month, billed annually, excluding VAT, with 3, 5 and 15 users included. Current prices are listed in euros on the Prim.io pricing page. A free demo account lets you test the system before you buy.

Key takeaways: a COGS checklist for ecommerce brands

Reliable ecommerce COGS starts with complete inventory costs and reconciled stock movements. Use the simplified reseller formula only where appropriate, include conversion costs for manufacturing, and compare channels using consistent definitions. Prim.io connects operational records and built-in AI to support that work; accounting policies and final checks remain essential.

  • Reconcile supplier invoices, discounts and inventory movements; include eligible conversion costs for manufacturing.
  • Factor inbound shipping and customs duties into landed cost.
  • Track manufacturing with production recipes and work-order records; reconcile incomplete production and additional cost allocations separately.
  • Use configured Qlik-powered BI reports to review product and channel margins, then account for fulfillment and channel fees consistently.

Open a free demo account

Free demo account. No credit card required.

Categories

Business tips
News
Publications

Meet an expert

Assess your project & get a tailored demo

Prefer to talk? Call our team directly.

Mon–Fri, 9am–6pm EET

Ready to see it for yourself?

The best way to understand Prim.io is to try it. Start with a free demo account and explore at your own pace.