How to Calculate Gross Profit Margin for an Online Store

Learn how to calculate gross profit margin for an online store with simple formulas and examples. Understand product costs, discounts, shipping, and pricing decisions.

By Hamza Aamir8 min readReviewed
Ecommerce gross profit margin calculation showing online store sales, cost of goods sold, and profit percentage.

Gross profit margin for an online store is calculated by subtracting the cost of goods sold (COGS) from net sales, dividing the result by net sales, and multiplying by 100. The formula is: Gross Profit Margin (%) = (Net Sales − COGS) ÷ Net Sales × 100. For example, if an online store generates $10,000 in net sales and has $6,000 in COGS, its gross profit is $4,000 and its gross profit margin is 40%. This measures profitability before other business expenses.

Key takeaways

  • Gross profit margin measures the percentage of net sales remaining after deducting the cost of goods sold (COGS).
  • The formula is (Net Sales − COGS) ÷ Net Sales × 100.
  • An online store with $10,000 in net sales and $6,000 in COGS has a 40% gross profit margin.
  • Product purchase costs and appropriate inbound freight generally contribute to inventory costs.
  • Discounts, returns, and changes in product costs can affect gross profit margin.
  • Gross profit margin differs from net profit margin because it does not account for all business expenses.
  • Tracking margins by product helps ecommerce sellers evaluate pricing and profitability.

Selling products online is not just about generating sales. You also need to understand how much money remains after paying for the products you sell.

Gross profit margin measures the percentage of sales revenue left after deducting the cost of goods sold (COGS). It helps online store owners evaluate product profitability, review pricing decisions, and identify changes in product costs.

In this guide, you will learn how to calculate gross profit margin for an online store, which expenses to include, and how discounts and product costs affect your results.

What Is Gross Profit Margin in Ecommerce?

Gross profit margin is a financial metric that shows how much of your net sales revenue remains after deducting the cost of goods sold.

For an online store, COGS generally includes the costs directly associated with the products sold, such as their purchase or manufacturing costs and other appropriately allocated costs.

For example, if your store generates $10,000 in net sales and the products sold cost $6,000, your gross profit is $4,000.

Your gross profit margin is 40%.

This does not mean your business earned $4,000 in net profit. Other expenses, such as advertising, administration, and applicable taxes, may still need to be deducted.

Gross Profit Margin Formula

The formula is:

Gross Profit Margin (%) = (Net Sales − Cost of Goods Sold) ÷ Net Sales × 100

Where:

  • Net Sales: Sales revenue after sales returns, allowances, and discounts, excluding taxes collected on behalf of tax authorities.

  • Cost of Goods Sold (COGS): The cost assigned to the products sold during the period.

  • Gross Profit: Net sales minus COGS.

Use net sales and COGS from the same reporting period.

Example: Calculating Gross Profit Margin

Suppose your online store has the following monthly results:

ItemAmount
Net sales$12,000
Cost of goods sold$7,200
Gross profit$4,800

Calculation:

($12,000 − $7,200) ÷ $12,000 × 100 = 40%

Your online store has a 40% gross profit margin.

This means $0.40 of every $1 in net sales remains after deducting COGS, before other business expenses.

How to Calculate Gross Profit Margin Step by Step

Step 1: Calculate Your Net Sales

Start with total product sales revenue for the period.

Subtract any sales returns, allowances, and discounts that reduce revenue.

For example:

  • Gross product sales: $15,000

  • Discounts: $1,000

  • Returns and allowances: $500

Net Sales = $15,000 − $1,000 − $500 = $13,500

Step 2: Calculate Cost of Goods Sold

Determine the cost of the products actually sold during the same period.

For a retailer, a common inventory-based formula is:

COGS = Beginning Inventory + Net Inventory Purchases − Ending Inventory

This simplified formula assumes the inventory figures and purchase costs are measured consistently and include appropriate inventory-related costs.

Example:

  • Beginning inventory: $5,000

  • Net inventory purchases: $9,000

  • Ending inventory: $6,000

COGS = $5,000 + $9,000 − $6,000 = $8,000

Step 3: Calculate Gross Profit

Gross Profit = Net Sales − COGS

Using the examples above:

$13,500 − $8,000 = $5,500

Step 4: Calculate Gross Profit Margin

Gross Profit Margin = $5,500 ÷ $13,500 × 100

Gross Profit Margin = 40.74% approximately

Your online store retains approximately 40.74% of net sales after the cost of goods sold.

What Costs Should an Online Store Include in COGS?

Understanding COGS is important because incorrect cost classifications can make gross profit margin misleading.

Product Purchase or Manufacturing Costs

These generally include the purchase cost of goods acquired for resale or the appropriate production costs of manufactured products.

Inbound Shipping and Freight

Freight-in and other costs necessary to bring inventory to its present location and condition are generally included in inventory costs, subject to the applicable accounting framework.

Import Duties and Nonrecoverable Taxes

Certain import duties and nonrecoverable purchase taxes may form part of inventory cost.

Packaging Costs

Packaging that is part of preparing a product for sale may be included in inventory costs, depending on its purpose and the accounting treatment used.

What About Advertising, Payment Fees, and Delivery to Customers?

These costs are not automatically part of inventory COGS.

  • Advertising is generally an operating expense.

  • Payment processing fees are typically treated as selling or operating expenses, depending on the accounting policies and reporting presentation.

  • Outbound shipping and fulfillment costs may be presented separately or included in a cost-of-revenue measure depending on the business and accounting policies.

For meaningful comparisons, use consistent classifications and clearly identify what your gross margin calculation includes.

Gross Profit Margin Example for a Shopify Store

Imagine an online clothing store with these monthly figures:

ItemAmount
Net sales$20,000
Product COGS$11,000
Gross profit$9,000
Gross profit margin45%

Calculation:

($20,000 − $11,000) ÷ $20,000 × 100 = 45%

The store's gross profit margin is 45%.

However, it may still have additional expenses:

  • Advertising: $2,000

  • Payment processing: $600

  • Outbound shipping: $1,200

  • Software and other operating costs: $700

Total listed additional expenses: $4,500.

If these are the only remaining expenses and there are no other income items or taxes, the simplified remaining profit would be:

$9,000 − $4,500 = $4,500

This illustrates why gross profit margin should not be confused with final business profitability.

How Discounts Affect Gross Profit Margin

Discounts can reduce your margin even when product costs remain unchanged.

Suppose a product costs $60 and normally sells for $100.

Original gross profit:

$100 − $60 = $40

Original gross profit margin:

$40 ÷ $100 × 100 = 40%

Now offer a 20% discount.

New selling price:

$100 × 0.80 = $80

New gross profit:

$80 − $60 = $20

New gross profit margin:

$20 ÷ $80 × 100 = 25%

A 20% price discount reduces the gross profit margin from 40% to 25% in this example.

This is why online sellers should evaluate discount campaigns using both sales volume and profitability.

How to Calculate Gross Profit Margin Per Product

Calculating margin for individual products helps you identify which items contribute more gross profit relative to their selling prices.

Use:

Product Gross Margin (%) = (Net Selling Price − Product COGS) ÷ Net Selling Price × 100

Example:

ProductSelling PriceCOGSGross Margin
Product A$50$3040%
Product B$80$4445%
Product C$120$9025%

Product B has the highest gross margin percentage in this example.

However, margin percentage alone does not determine which product generates the most total profit. Sales volume and additional expenses also matter.

How to Set Prices Using a Target Gross Profit Margin

If you know your product cost and desired gross margin, you can estimate the required selling price.

Formula

Selling Price = Product Cost ÷ (1 − Target Gross Margin ÷ 100)

This formula assumes the target margin is below 100% and the cost is positive.

Example: Target 35% Margin

Suppose a product costs $65.

You want a 35% gross profit margin.

Selling Price = $65 ÷ (1 − 0.35)

Selling Price = $65 ÷ 0.65 = $100

A selling price of $100 produces a 35% gross profit margin.

Remember that gross margin is not the same as markup. Markup is calculated using cost rather than selling price.

For a detailed explanation, read our guide: Profit Margin vs Markup: Formulas, Differences and Examples.

Gross Profit Margin vs Net Profit Margin

Gross profit margin focuses on net sales after deducting COGS.

Net profit margin measures net income as a percentage of revenue after all applicable expenses and taxes.

Example

Suppose an online store reports:

  • Net sales: $25,000

  • COGS: $15,000

  • Gross profit: $10,000

  • Remaining expenses and taxes: $7,000

  • Net income: $3,000

Gross profit margin:

$10,000 ÷ $25,000 × 100 = 40%

Net profit margin:

$3,000 ÷ $25,000 × 100 = 12%

The business has a 40% gross profit margin but a 12% net profit margin.

Both metrics are useful for evaluating financial performance.

What Is a Good Gross Profit Margin for an Online Store?

There is no single gross profit margin that is ideal for every ecommerce business.

A suitable margin depends on factors such as:

  • Product category

  • Supplier and manufacturing costs

  • Competition

  • Customer acquisition costs

  • Shipping and fulfillment expenses

  • Return rates

  • Pricing strategy

  • Business model

For example, businesses selling highly competitive commodity products may operate with different margins from businesses selling differentiated or premium products.

Instead of relying on a universal benchmark, compare your results with relevant businesses and monitor your own margins over time.

Common Gross Profit Margin Mistakes

1. Using Gross Sales Instead of Net Sales

Ignoring returns and discounts can overstate the revenue used in your calculation.

2. Mixing Different Reporting Periods

Using sales from one month and COGS from another can produce misleading results.

3. Confusing Gross Margin With Markup

A 40% markup does not equal a 40% gross profit margin.

A 40% markup produces a gross profit margin of approximately 28.57%.

4. Ignoring Inventory Cost Changes

Supplier price increases, freight costs, and inventory valuation changes can affect COGS.

5. Treating Gross Profit as Net Profit

Gross profit does not account for every expense required to run an online business.

6. Comparing Businesses With Different Cost Classifications

Two businesses may classify fulfillment and other costs differently. Check their accounting definitions before comparing gross margin percentages.

How to Improve Your Online Store's Gross Profit Margin

Review Supplier Costs

Negotiate purchasing terms, compare suppliers, and monitor changes in landed product costs.

Adjust Pricing Carefully

Review selling prices based on demand, competition, product positioning, and target margins.

Reduce Product Returns

Accurate descriptions, product images, sizing information, and quality control may help reduce returns.

Monitor Discounts

Evaluate promotions based on the gross profit they generate, not just the revenue they produce.

Analyze Individual Products

Track product-level margins to identify items with unusually high costs or weak pricing.

Improve Inventory Management

Monitor slow-moving products, damaged inventory, and stock losses that may affect costs.

Frequently Asked Questions

How do you calculate gross profit margin for an online store?

Subtract cost of goods sold from net sales, divide the result by net sales, and multiply by 100.

Is a 40% gross profit margin good for ecommerce?

It depends on your product category, operating expenses, competition, and business model. A 40% gross margin may be suitable for one business but insufficient for another.

Does shipping count toward COGS?

Inbound freight necessary to acquire inventory is generally included in inventory cost. Outbound delivery to customers may be classified differently depending on the business and applicable accounting policies.

Are advertising costs included in gross profit margin?

Advertising expenses are generally excluded from inventory COGS and deducted elsewhere when calculating operating or net profitability.

What is the difference between gross profit and gross profit margin?

Gross profit is a monetary amount. Gross profit margin expresses gross profit as a percentage of net sales.

Can gross profit margin be negative?

Yes. Gross profit margin can be negative when COGS exceeds net sales.

How do returns affect gross profit margin?

Returns generally reduce net sales and may also affect COGS when returned products are restored to inventory. The overall impact depends on the condition and accounting treatment of the returned goods.

Final Thoughts

Gross profit margin is one of the most useful financial metrics for an online store.

By calculating net sales, identifying the correct cost of goods sold, and applying the gross margin formula, you can better understand product profitability and make more informed pricing decisions.

Review your margins regularly, particularly when product costs, discounts, and selling prices change.

Frequently asked questions

How do you calculate gross profit margin for an online store?

Subtract the cost of goods sold from net sales, divide the result by net sales, and multiply by 100. For example, $10,000 in net sales minus $6,000 in COGS produces a 40% gross profit margin.

What is a good gross profit margin for ecommerce?

There is no universal ideal margin. A suitable gross profit margin depends on the product category, supplier costs, competition, pricing strategy, and operating expenses.

Is shipping included in ecommerce COGS?

Inbound freight required to acquire inventory is generally included in inventory costs. Outbound shipping to customers may be classified differently depending on the accounting policies used.

Are advertising costs included in gross profit margin?

Advertising is generally treated as an operating expense rather than inventory COGS. It affects operating and net profitability but is normally excluded from a traditional gross profit margin calculation.

What is the difference between gross profit and gross profit margin?

Gross profit is the monetary amount remaining after subtracting COGS from net sales. Gross profit margin expresses that amount as a percentage of net sales.

How do discounts affect gross profit margin?

Discounts reduce selling prices and usually reduce gross profit margin when product costs remain unchanged. For example, discounting a $100 product costing $60 to $80 reduces its gross margin from 40% to 25%.

Can an online store have a negative gross profit margin?

Yes. Gross profit margin becomes negative when the cost of goods sold exceeds net sales for the reporting period.

References

Back to all articles