Free Tool
COGS Calculator
Calculate your cost of goods sold using the standard accounting formula. Enter your beginning inventory, purchases, and ending inventory to get your COGS and gross margin instantly.
Researched by the ShelfMerge Research Team
Inventory value at the start of the period
All inventory purchased or manufactured this period
Inventory value remaining at period end
Add revenue to calculate gross margin
What COGS actually measures
Cost of goods sold is the direct cost of the inventory you moved during a period. The formula has three inputs: what you had at the start, what you added, and what you still had at the end. Everything in the middle — the goods that left your possession through sales, damage, or shrinkage — becomes COGS.
The formula is: COGS = Beginning Inventory + Purchases − Ending Inventory. This works for product-based businesses regardless of whether you manufacture, wholesale, or dropship. The key is consistent valuation: use cost price throughout, never retail price.
What counts — and what does not
COGS includes: supplier invoice cost, inbound freight and customs duties, packaging materials that ship with the product, and direct manufacturing labor. It does not include Shopify subscription fees, advertising spend, warehouse rent, customer service payroll, or merchant processing fees. Those belong in operating expenses, below the gross profit line.
Getting this line wrong — putting ad spend into COGS, for instance — inflates your apparent COGS ratio and makes products look less profitable than they are. The reverse mistake (leaving out inbound freight) understates COGS and overstates gross margin, which can lead to pricing decisions that erode margin at scale.
Why Shopify merchants need to track COGS precisely
Shopify's native analytics shows revenue and orders, but it does not automatically calculate COGS unless you enter product costs manually for every SKU. Most merchants skip this step. The result: they know their top-line revenue but have no reliable gross margin figure — which means they cannot tell whether their ad spend is profitable or which product categories actually make money.
A Shopify store running $200,000/month in revenue with a 60% COGS ratio has $80,000 in gross profit. That $80,000 needs to cover all operating expenses. If COGS is actually 70% because inbound freight and duties were excluded, gross profit drops to $60,000 — and the business math looks completely different. Small percentage errors on high-volume stores create large cash mismatches.
Common COGS mistakes in ecommerce
- Using retail price instead of cost price when valuing ending inventory
- Forgetting inbound shipping costs — especially for international suppliers
- Mixing cash accounting and accrual accounting within the same period
- Not adjusting for returns — returned goods that go back to stock should reduce COGS
- Ignoring damaged or shrinkage inventory that never sold but leaves cost behind
Common questions about cost of goods sold
How to use this cost of goods sold tool
Install from the Shopify App Store
OAuth takes 30 seconds. ShelfMerge requests read_products and write_products scopes — nothing more. No credit card for the Free plan.
Run your first scan
ShelfMerge pulls your full product catalog and runs all three detection layers simultaneously. A 2,000-product store scans in under 8 seconds.
Review duplicates, merge in bulk
Duplicates are grouped by confidence score. Select a group, pick the primary product, click Merge. The duplicate is archived and variants consolidated. Click Undo at any time.
Common questions about cost of goods sold
Will ShelfMerge permanently delete my products?
No. ShelfMerge archives the duplicate product — it moves to Archived status in your Shopify admin and remains fully recoverable. Before any merge, ShelfMerge creates a complete snapshot of both products. You can restore to the exact pre-merge state from the Merge History tab at any time.
How does fuzzy title matching work without creating false positives?
We use Levenshtein distance with a configurable threshold (default 85% similarity). Every match is assigned a confidence score from 0-100%. Matches above 95% are "High confidence". Matches below 70% are flagged "Review needed". You always see the score before deciding to merge.
Does ShelfMerge work with stores that have thousands of products?
Yes. We use cursor-based pagination against the Shopify Admin API with a built-in rate limiter (2 req/s, burst 40). A 10,000-product store scans in under 60 seconds. The Agency plan is tested against catalogs up to 50,000 products.
What happens to variant inventory when I merge products?
Variants from the duplicate are consolidated onto the primary product. Inventory quantities are summed. Pricing, weight, and fulfillment settings from the primary product take precedence. The merge preview shows exactly which variant data will change before you confirm.
Automate COGS tracking for your entire Shopify catalog
ShelfMerge connects directly to your Shopify store and runs this analysis automatically — across your entire catalog, updated daily.
Free plan — no credit card required.