How to Calculate COGS (Cost of Goods Sold) for Ecommerce Businesses
For ecommerce founders and operators, few metrics are as critical—or as frequently misunderstood—as the Cost of Goods Sold (COGS). Whether you are an Amazon FBA seller, a Shopify merchant, a manufacturer, or a multi-channel brand, your COGS is the foundational number that dictates your gross profit margin, influences your pricing strategy, and ultimately determines the financial viability of your business.
Despite its importance, many ecommerce businesses struggle to calculate COGS accurately. Some exclude crucial direct costs, artificially inflating their perceived profitability. Others conflate COGS with operating expenses, leading to skewed financial statements and potential issues with the IRS. In the highly competitive world of ecommerce, where margins are often razor-thin, an inaccurate COGS calculation can be the difference between scaling successfully and quietly bleeding cash.
In this comprehensive guide, we will break down exactly how to calculate COGS for ecommerce businesses. We will explore the standard COGS formula, detail exactly what should and should not be included, compare COGS to landed cost, and examine the profound impact this metric has on your profit margins and tax liabilities. We will also walk through a practical, real-world example and highlight common mistakes to avoid.
What is Cost of Goods Sold (COGS)?
Cost of Goods Sold (COGS) represents the direct costs attributable to the production or procurement of the goods sold by a company. In the context of ecommerce, this means all the expenses directly tied to acquiring a product and getting it ready for sale. It is a measure of the direct cost incurred to generate revenue.
COGS is subtracted from your total revenue (gross sales) to determine your gross profit. This makes it a pivotal figure on your income statement. If your COGS is too high relative to your selling price, your gross profit margin will be too low to cover your operating expenses (like marketing, software, and payroll), resulting in a net loss.
The Standard COGS Formula
The fundamental formula for calculating COGS over a specific accounting period (such as a month, quarter, or year) is straightforward:
COGS = Beginning Inventory + Purchases During the Period - Ending Inventory
Let us break down each component of this formula:
- Beginning Inventory: The total value of all inventory you had in stock at the exact start of the accounting period. This should match the ending inventory of the previous period.
- Purchases During the Period: The total cost of all new inventory purchased or manufactured during the period. This includes the cost of the products themselves, plus any direct costs required to get them into your warehouse (more on this below).
- Ending Inventory: The total value of all inventory remaining in stock at the exact end of the accounting period.
This formula calculates the cost of the inventory that actually left your warehouse (i.e., was sold) during the period. It ensures you are only matching the cost of the goods against the revenue generated by those specific goods, adhering to the matching principle in accounting.
What is Included in COGS vs. Excluded?
The most common source of error in calculating COGS is misclassifying expenses. The golden rule is that COGS only includes direct costs associated with producing or acquiring the product. It does not include indirect costs or operating expenses (OPEX).
What to Include in COGS
For an ecommerce business, the following costs are typically included in COGS:
- Wholesale Price of Goods: The actual amount paid to your supplier or manufacturer for the products.
- Raw Materials: If you manufacture your own products, the cost of all raw materials used in production.
- Direct Labor: The wages of employees directly involved in manufacturing or assembling the product (less common for dropshippers or standard retailers, but crucial for makers).
- Inbound Freight and Shipping: The cost to transport the goods from your manufacturer to your warehouse or 3PL (Third-Party Logistics) provider.
- Customs, Duties, and Tariffs: Any taxes or fees paid to import the goods into your country of sale.
- Packaging Materials: The cost of the primary packaging that holds the product (e.g., the custom box the product sits in), and sometimes the secondary shipping materials (e.g., the poly mailer or corrugated box used to ship to the customer), depending on your accounting method.
What to Exclude from COGS (Operating Expenses)
The following costs are considered operating expenses (OPEX) and should never be included in your COGS calculation:
- Marketing and Advertising: Facebook ads, Google Ads, influencer payments, and SEO agency fees.
- Software Subscriptions: Shopify fees, email marketing software, inventory management systems, and accounting software.
- General Payroll: Salaries for management, marketing teams, customer service representatives, and administrative staff.
- Office Rent and Utilities: The cost of leasing office space, internet, and electricity (unless it is a manufacturing facility directly tied to production).
- Outbound Shipping (Usually): The cost to ship the final product to the end customer is typically classified as a fulfillment expense or selling expense, not COGS, though some businesses choose to group it differently for internal analysis.
- Platform Fees: Amazon referral fees, Shopify transaction fees, and credit card processing fees.
COGS vs. Landed Cost: Understanding the Difference
In ecommerce, you will frequently hear the terms "COGS" and "Landed Cost" used interchangeably. While they are closely related, they are not exactly the same thing, and understanding the distinction is vital for accurate pricing and profitability analysis.
Landed Cost is the total price of a product once it has arrived at your warehouse or fulfillment center, ready to be sold. It is a per-unit metric. Landed cost includes the unit price paid to the supplier, plus inbound freight, customs, duties, insurance, and any other fees incurred to get that single unit to your door.
COGS, on the other hand, is an aggregate metric used on your income statement over a specific period. It represents the total cost of all the units you actually sold during that time.
Essentially, your Landed Cost per unit is the primary input used to calculate your total COGS. If your landed cost for a widget is $10, and you sell 1,000 widgets in a month, your COGS for that month is $10,000. Calculating an accurate landed cost is the prerequisite for calculating an accurate COGS.
The Impact of COGS on Profit Margins
Your COGS directly dictates your Gross Profit and Gross Margin. These are the most fundamental indicators of your business\'s financial health.
- Gross Profit = Total Revenue - COGS
- Gross Margin = (Gross Profit / Total Revenue) x 100
Let us look at an example. If you sell a product for $50 and your COGS is $15, your Gross Profit is $35, and your Gross Margin is 70%. This means you have 70 cents of every dollar left over to cover your operating expenses and generate a net profit.
If your COGS increases to $25 due to rising freight costs, your Gross Profit drops to $25, and your Gross Margin plummets to 50%. Suddenly, you have significantly less money to spend on marketing or software, putting immense pressure on your bottom line.
This is where tools like ProfitBeacon become invaluable. ProfitBeacon integrates directly with your sales channels and advertising platforms to provide real-time visibility into your true profitability. By accurately tracking your COGS alongside your marketing spend and platform fees, ProfitBeacon allows you to see your exact net margin on a per-SKU basis, ensuring you never scale a product that is secretly losing money.
IRS and Accounting Implications of COGS
Beyond internal decision-making, COGS is a critical component of your tax return. In the United States, the IRS requires businesses that manufacture or buy and sell merchandise to calculate COGS to determine their gross profit, which is then used to calculate taxable income.
Because COGS is an expense, a higher COGS reduces your taxable income, which in turn reduces your tax liability. Conversely, a lower COGS increases your taxable income and your tax bill.
This creates a strict regulatory environment. You cannot arbitrarily inflate your COGS to lower your taxes; doing so is tax fraud. The IRS requires you to use a consistent inventory valuation method (such as FIFO, LIFO, or Average Cost) and to maintain meticulous records of your beginning inventory, purchases, and ending inventory.
- FIFO (First-In, First-Out): Assumes the oldest inventory is sold first. In a period of rising prices, FIFO results in a lower COGS and higher taxable income.
- LIFO (Last-In, First-Out): Assumes the newest inventory is sold first. In a period of rising prices, LIFO results in a higher COGS and lower taxable income. (Note: LIFO is permitted under US GAAP but banned under IFRS).
- Average Cost: Calculates a weighted average cost for all units available for sale during the period.
Choosing the right valuation method and maintaining accurate records is essential for compliance and optimal tax planning. Always consult with a certified public accountant (CPA) to ensure your COGS calculations meet regulatory standards.
Common Mistakes in Calculating COGS
Even experienced ecommerce operators can make errors when calculating COGS. Here are some of the most common pitfalls to avoid:
- Ignoring Inbound Freight and Duties: Many sellers only use the supplier\'s invoice price as their COGS. Failing to include the cost of shipping the goods from the factory to the warehouse, along with customs duties, drastically understates COGS and overstates profit.
- Failing to Account for Shrinkage: Inventory shrinkage refers to goods lost due to theft, damage, or administrative errors. If you do not perform regular physical inventory counts and adjust your ending inventory for shrinkage, your COGS will be inaccurate.
- Mixing OPEX with COGS: As discussed earlier, including marketing costs, platform fees, or general administrative salaries in COGS distorts your gross margin and makes it impossible to evaluate the fundamental profitability of your products.
- Inconsistent Valuation Methods: Switching between FIFO and Average Cost from year to year without IRS approval is a major compliance violation and makes year-over-year financial comparisons meaningless.
- Relying on Outdated Costs: Supplier prices and freight rates fluctuate constantly. If you are using a static COGS figure from six months ago, your current profitability metrics are likely wrong.
Worked Example: Calculating COGS for an Ecommerce Brand
Let us walk through a practical example to illustrate how the COGS formula works in reality. Imagine you run a Shopify store selling premium yoga mats. You are calculating your COGS for the first quarter (Q1) of the year.
Step 1: Determine Beginning Inventory
On January 1st, you conduct a physical inventory count and determine you have 500 yoga mats in stock. Based on your historical landed cost calculations, each mat cost you $12 to acquire (including the product cost, inbound shipping, and duties).
- Beginning Inventory Value: 500 units x $12/unit = $6,000
Step 2: Calculate Purchases During the Period
In February, you place a new order for 2,000 yoga mats. However, freight costs have increased. The breakdown of this new purchase is as follows:
- Supplier Invoice (2,000 units @ $10/unit): $20,000
- Inbound Ocean Freight: $4,000
- Customs and Duties: $1,000
The total cost of this new purchase is $25,000. This means your new landed cost per unit is $12.50 ($25,000 / 2,000 units).
- Purchases During the Period: $25,000
Step 3: Determine Ending Inventory
On March 31st, at the end of Q1, you conduct another physical count. You have 800 yoga mats remaining in stock. Assuming you use the FIFO (First-In, First-Out) method, these 800 remaining mats are from your most recent batch, which had a landed cost of $12.50 per unit.
- Ending Inventory Value: 800 units x $12.50/unit = $10,000
Step 4: Apply the COGS Formula
Now, we plug these figures into the standard COGS formula:
COGS = Beginning Inventory ($6,000) + Purchases ($25,000) - Ending Inventory ($10,000)
- Total Q1 COGS: $21,000
During Q1, the cost of the goods you actually sold was $21,000. If your total revenue for Q1 was $60,000, your Gross Profit would be $39,000 ($60,000 - $21,000), resulting in a Gross Margin of 65%.
Conclusion: Mastering COGS for Sustainable Growth
Calculating Cost of Goods Sold is not just an accounting exercise required by the IRS; it is a fundamental operational necessity for any ecommerce business aiming for sustainable growth. An accurate COGS calculation provides the baseline for your pricing strategy, informs your marketing budget, and reveals the true health of your product portfolio.
By understanding the difference between direct costs and operating expenses, accurately calculating your landed cost, and consistently applying the COGS formula, you can avoid the common pitfalls that erode profitability. Remember that COGS is a dynamic metric. As supplier prices, freight rates, and customs duties fluctuate, your COGS will change, and your financial models must adapt accordingly.
Managing these fluctuations manually across spreadsheets is a recipe for error and delayed decision-making. To truly master your margins, you need real-time visibility into your costs. ProfitBeacon automates this process, pulling data from your sales channels, advertising platforms, and cost inputs to provide a unified, accurate view of your true profitability. Stop guessing at your margins and start making data-driven decisions. Sign up for ProfitBeacon today and take control of your ecommerce finances.
Related reading
- How to Calculate Landed Cost in 2026 -- the full breakdown of every cost that feeds into COGS for imported products.
- Wholesale Pricing Formula: How to Set Wholesale Prices Without Killing Your Margins -- once you know your COGS, use this guide to set channel prices that protect your margin.
- What Is a Good Profit Margin for Ecommerce? (2026 Benchmarks) -- benchmark your gross margin against industry averages by category.
Put these numbers to work
Run a real product analysis with landed cost, tariffs, and all fees calculated automatically.
Related Articles