The Webgility Blog | Ecommerce Content To Help Grow Your Business

How to calculate COGS: A Complete Guide for eCommerce Businesses

Written by Parag Mamnani, Webgility CEO | May 19, 2025 6:05:21 AM

One costly mistake can sink your business. 

No online retailer would want to come across a situation where they cannot understand every expense on their items ready for sale, from raw materials and labour to shipping and storage. This can make them incapable of making confident business decisions, setting smart prices, and maximizing profit. 

To avoid getting trapped in this scenario, learn how to calculate COGS (Cost of Goods Sold) correctly. It will help you illustrate the direct and indirect costs associated with producing or acquiring the products you sell online. 

Thus, if you know how to master your COGS calculations, you can identify how many "invisible" expenses were eating away at your margins and grasp your true profitability.  

In this comprehensive guide, we'll break down all you need to know about COGS— what it is, how to calculate COGS and common mistakes you should avoid while calculating it. We’ll also dive into the nitty-gritty of direct and indirect costs to optimize your financial planning, pricing strategies, and resource allocation. 

Understanding cost of goods sold (COGS) for  ecommerce

COGS goes beyond just the product purchase price. It encompasses a wide range of expenses, both direct and indirect, that contribute to getting your products ready for sale. From raw materials and labour costs to shipping and overhead expenses, every penny counts when calculating the COGS for your business.

Direct expenses are directly traced to getting your products ready for sale and delivered to customers. These costs form the foundation of COGS calculation and typically include product purchase or production costs, direct labour costs, inbound shipping and freight, packaging expenses, warehousing (direct storage) costs, etc. 

When calculating your true COGS as an online retailer, it's easy to focus solely on what you paid for acquiring or manufacturing that product. However, numerous expenses that cannot be directly traced to a specific product significantly impact your actual cost of getting products ready for sale. 

These are called indirect expenses that are overlooked by online retailers. These typically include marketing and advertising expenses, equipment depreciation, insurance, distribution costs, inspection labour and refurbishing costs for returned items, replacement costs for defective items, and more. 

Importance of COGS in ecommerce

Global retail ecommerce sales are estimated to exceed $6 trillion in 2024. Projections indicate a 31 percent growth in this figure, making it reach $8 trillion by 2028, highlighting the scale and complexity of cost management in ecommerce. 

Think of COGS as the foundation that supports nearly every financial decision you make. It is highly unlikely to run a successful ecommerce business without knowing how to calculate COGS due to its direct impact on profitability, pricing, and strategic decision-making. 

When you know exactly what it costs to get your products into customers' hands, you can make smarter choices across your entire business. So, here are some facts that state why COGS is crucial for ecommerce businesses:

  • Foundation for pricing: Your COGS is the foundation for determining the right price point for your products. By accurately calculating the direct and indirect costs associated with each item, you can set prices that cover your expenses while still allowing for a healthy profit margin. 
  • Budgeting and financial planning: Accurately tracking your COGS enables you to forecast your future expenses, allocate resources effectively, and make informed decisions about inventory levels, staffing needs, and other operational costs. 
  • Inventory and supply chain management strategies: By understanding the true cost of each product, you can optimize your inventory levels, minimizing the risk of overstocking or stockouts. Additionally, COGS calculation allows you to identify opportunities to streamline your supply chain, negotiate better deals with suppliers, and explore more cost-effective sourcing options

📝 A Quick Note: Every major decision-whether it’s about pricing, inventory, ad spend, or staffing-relies on having an accurate COGS number. Getting this wrong can lead to costly mistakes across your business.

Also read: Boost Ecommerce Profits: 10 Ways to Drive Revenue

Breaking down direct and indirect costs to calculate COGS

Understanding the distinction between direct and indirect costs is essential for accurate budgeting and financial analysis. Here is the difference:

1. Direct costs in COGS

Direct costs are the expenses directly attributable to the production or acquisition of the goods you sell. These costs are easily traceable to a specific product, order, or batch and are essential for determining the true cost of each unit sold. 

Direct costs include all expenses related to:

  • Raw materials involved in manufacturing the product 
  • Labour for crafting each piece if you manufacture your product
  • Packaging 
  • Product labels or tags

Besides, direct costs can also encompass expenses like:

  • Purchase price of inventory from suppliers if you acquire the manufactured product
  • Shipping and freight costs (inbound) to bring inventory to your warehouse or fulfilment centre
  • Import duties or taxes on materials sourced internationally
  • Customs fees and import duties (if applicable)
  • Direct labour costs if you manufacture your own products

The key factor that sets direct costs apart is their direct correlation to the goods sold. If you didn't produce or acquire those products, you wouldn't incur these expenses.

2. Indirect costs in ecommerce

There’s another side to the story: the indirect costs. 

An indirect cost is any expense that cannot be directly attributed to the production of a specific product or service but is necessary for overall business operations. In accounting terms, these are often called overhead costs.

Unlike direct costs (such as raw materials or manufacturing labour) that can be easily traced to specific products, indirect costs support the entire business infrastructure. They would continue to exist even if you temporarily stopped selling a particular product line.

Examples of indirect costs include:

  • Rent or mortgage payments for your office or warehouse space
  • Utilities like electricity, water, and internet
  • Administrative staff salaries and benefits
  • Marketing and advertising expenses
  • Professional services like accounting or legal fees
  • Equipment maintenance and repairs
  • Software subscriptions and licensing fees
  • Business, liability, or property insurance covering your ecommerce operations

But that’s not all. Indirect costs can also include the gradual wear-and-tear (depreciation) on your equipment.

Thinking about how indirect costs play a massive role in your overall profitability? Calculating indirect expenses enables you to create accurate pricing strategies, analyze profitability, and ensure long-term business growth.

Furthermore, when you track these indirect costs, it will allow you to identify areas where you can reduce expenses or increase efficiency, freeing up more resources to invest in growth while keeping prices competitive.

Step-by-step guide on how to calculate COGS for online retailers

Accurately tracking your COGS is crucial to maximize profits for your online business. However, with inventory constantly moving and costs fluctuating, it can become daunting to calculate COGS. 

By following these simple yet effective steps and utilizing the right tools, you can streamline COGS calculation:

1. Understand what COGS includes

COGS represents the direct costs tied to the products you sell. For online retailers, this typically includes:

  • Cost of purchasing inventory (products for resale)
  • Shipping and freight costs to receive inventory
  • Direct labour (if you manufacture the product)
  • Packaging costs
  • Any other costs directly attributable to acquiring or producing the goods

📝 A Quick Note: Indirect costs are excluded from calculating COGS as they don't directly contribute to the production or acquisition of goods. However, considering this cost will help you provide a more accurate picture of the true cost of goods sold, leading to better profitability analysis and pricing decisions.

2. Gather key inventory numbers

To calculate COGS, you need three main figures for the period (usually a month, quarter, or year):

  • Beginning Inventory: The value of inventory you have at the start of the period. This should match the ending inventory from the previous period
  • Purchases: The total cost of inventory bought during the period, including shipping and any other direct costs
  • Ending Inventory: The value of inventory left unsold at the end of the period. This should be determined by a physical count or a reliable inventory system

Doing this manually can be tedious and error-prone. This is where you can use a potent multi-channel inventory management tool like Webgility. It automatically syncs inventory quantities, prices, and sales data, ensuring that your inventory records are always accurate and up-to-date across all platforms

3. The COGS formula

The standard formula for calculating COGS is:

COGS = Beginning Inventory + Purchases − Ending Inventor

This formula works for most online retailers using periodic inventory accounting.

4. Apply the COGS formula (example)

Here is an example of how to calculate COGS using the formula:

Suppose:

  • Beginning Inventory: $10,000
  • Purchases during the period: $5,000
  • Ending Inventory: $4,000

Plug into the formula:

COGS = $10,000 + $5,000 − $4,000 = $11,000
COGS = $10,000 + $5,000 − $4,000 = $11,000

5. Choose your inventory valuation method

If your inventory costs fluctuate, choose a method for assigning costs:

  • FIFO (First-In, First-Out): Oldest inventory costs are used first. Common for perishable goods
  • LIFO (Last-In, First-Out): The newest inventory costs are used first. Less common for ecommerce, more for non-perishables
  • Weighted Average Cost: Average cost per unit is used, suitable for businesses with many similar items
  • Specific Identification: Track the exact cost of each item suitable for high-value or unique products

6. Record and review regularly

  • Keep accurate records of purchases and inventory counts
  • Regularly reconcile your physical inventory with your records to avoid discrepancies
  • Review your COGS calculation each period to ensure accuracy and to inform pricing and profitability decisions

Summary table: How to calculate COGS

Here’s a quick recap of what we have gone through in the above section:

Step
Action

Identify costs

List all direct costs for goods sold

Gather inventory data

Record beginning inventory, purchases, and ending inventory

Apply formula

COGS = Beginning Inventory + Purchases - Ending Inventory

Choose valuation method

FIFO, LIFO, Weighted Average, or Specific Identification

Record & review

Keep records updated and review regularly for accuracy

Common errors in COGS calculation and how to avoid them

 

Accurately calculating the cost of goods sold (COGS) is crucial for ecommerce businesses, but it's also an area where many make costly mistakes. Overlooking or miscalculating certain costs can lead to inaccurate financial reporting, pricing issues, and ultimately, lower profits. Here are common pitfalls and how to steer clear of them:

  • Not considering all direct expenses

Don’t just set product prices after taking into account raw material, shipping, and packaging costs; instead, take all direct expenses into consideration to calculate COGS accurately

  • Mixing up costs

Separate direct costs from indirect expenses like marketing or admin to keep your numbers clean

  • Inventory valuation mistakes

Use a consistent method (FIFO, LIFO, or weighted average) and keep inventory data updated to prevent errors

  • Inventory management errors

Conduct regular inventory counts to avoid discrepancies

  • Lack of integration between ecommerce and accounting systems

Integrate your ecommerce platform with accounting software to streamline COGS tracking. Automated data syncing reduces manual entry errors and provides real-time visibility into your true product costs

💡Pro Tip: Use ecommerce accounting automation software to connect your sales and accounting data seamlessly. It will help you save time, reduce mistakes, and determine true product costs to ensure you set the right price for your product and make smarter business decisions.

Strategies for reducing COGS in ecommerce landscape

Minimizing your COGS is one of the smartest ways to boost your ecommerce profit margins. While you can’t always automate shipping (without a tool) or control payment processing fees, you have real influence over your product sourcing costs—and that’s where strategic action makes a difference. 

Here’s how you can take charge and reduce COGS for your ecommerce business:

1 Negotiate better deals with suppliers

Don’t settle for the first price you are offered. Take the time to shop around, pay upfront, or commit to minimum order quantities (MOQs) to get discounts. You can also consider sourcing directly from manufacturers or importing to avoid markups. 

2 Bulk up on inventory (When It makes sense)

Volume-based pricing from suppliers makes buying in bulk a smart move for your best-selling products. Remember, bulk orders save money, but watch for storage costs and overstock risk as well. Use accurate inventory forecasting to balance savings and cash flow.

3 Diversify your supplier base

Don't put all your eggs in one basket. Having multiple vetted suppliers for key products gives you negotiating power and helps protect your business from unexpected supply chain disruptions. An added bonus? Splitting orders between vendors can help you score bulk pricing without carrying as much overstock risk.

4 Streamline procurement with ecommerce automation software

Let automated inventory management systems do the heavy lifting in your procurement process. Using these tools, you can optimize your procurement process in ways your team simply can't match manually. For instance, AI-powered demand forecasting lets you place smarter bulk orders to maximize volume discounts without overbuying. 

Final thoughts

The key to setting the right prices, managing inventory and understanding your true profit margins is calculating COGS. However, with fluctuating costs, different sales channels and inventory movements, tracking COGS can become overwhelming. 

So, what’s the solution? Integrating the right accounting tools streamlines your finances by automating tedious tasks and providing real-time visibility into your COGS, revenue, expenses, margins, and more. 

But with so many options, how do you choose?

Take control of your COGS with Webgility

For smaller or mid-sized operations, cloud-based solutions such as QuickBooks and NetSuite can easily track and manage inventory and automatically adjust COGS when sales transactions are recorded.
 
No wonder, if you’re already using (or plan to use) QuickBooks or NetSuite, Webgility acts as the bridge that brings together your sales, inventory, and accounting, needed for accurate COGS calculation. 

Make smarter business decisions and maximize profitability with Webgility

With Webgility, you can connect your online stores, marketplaces (like Amazon, eBay, Shopify, and Walmart), and POS systems directly to QuickBooks or NetSuite, syncing all your sales, returns, fees, and payouts in real-time. The platform also captures marketplace fees, shipping costs, and sales taxes to ensure accurate COGS calculations and a real-time view of your true profitability. 

By choosing our ecommerce automation platform, you can focus on scaling your brand—not crunching numbers. Sign up and get started for free today!