> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upstackdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upstack Costs

> Configure handling costs, fulfillment costs, per-order costs, fixed costs, and OPEX in Upstack Data to calculate accurate contribution margin and profitability metrics.

Upstack Costs is an internal data source where you configure your business costs for accurate margin and profitability calculations. Unlike other sources that pull data from external platforms, Upstack Costs uses values you configure directly in the Upstack dashboard.

## What Upstack Costs Provides

Upstack Costs powers metrics in the **Orders** category, including:

* **Handling Costs** — Per-unit costs for picking, packing, and processing
* **Fulfillment Costs** — Shipping and delivery costs
* **Transaction Costs** — Payment gateway fees
* **Cost of Goods Sold (COGS)** — Product costs (auto-pulled from Shopify, overridable)
* **Fixed Costs & OPEX** — Monthly operating expenses

These costs feed into contribution margin calculations (CM1, CM2, CM3, CM4) and profitability metrics.

## How It Works

<Steps>
  <Step title="Navigate to Cost Settings">
    In your Upstack dashboard, go to **Settings → Cost Management**.
  </Step>

  <Step title="Configure variable costs">
    Set up variable costs:

    * **Handling fee** — Fixed amount charged on every unit sold (e.g., \$2.50)
    * **Shipping cost** — Fixed amount or percentage of order value
    * **Gateway/transaction fees** — Percentage of order value (e.g., 2.9% + \$0.30)
  </Step>

  <Step title="Configure COGS">
    Choose how COGS are calculated:

    * **From Shopify** — Auto-pulled from product cost data in Shopify (default)
    * **Fixed percentage** — Set a default percentage of net revenue (e.g., "10% of net revenue")
    * **Custom per-product** — Override COGS for specific products
  </Step>

  <Step title="Configure fixed costs">
    Add monthly operating expenses:

    * **Agency fees** — Monthly retainer or percentage of ad spend
    * **Software costs** — Monthly SaaS subscriptions
    * **Other OPEX** — Any other fixed monthly costs
  </Step>
</Steps>

## Cost Data Sources

| Cost Type                  | Default Source             | Override Options             |
| -------------------------- | -------------------------- | ---------------------------- |
| **COGS**                   | Shopify product cost field | Fixed %, custom per-product  |
| **Handling**               | Upstack Cost Settings      | Per-order amount             |
| **Shipping (fulfillment)** | Upstack Cost Settings      | Fixed or % of order          |
| **Gateway fees**           | Upstack Cost Settings      | % of order + fixed fee       |
| **Agency fees**            | Upstack Cost Settings      | Monthly amount or % of spend |
| **OPEX**                   | Upstack Cost Settings      | Monthly amount               |

## COGS Configuration

Cost of Goods Sold is the only cost type with multiple data source options:

### Option 1: Auto-pull from Shopify (Recommended)

If your Shopify products have cost data populated, Upstack automatically pulls this for accurate per-product COGS calculations.

<Info>
  To populate product costs in Shopify, go to **Products → \[Product] → Pricing → Cost per item**.
</Info>

### Option 2: Default percentage

Set a blanket COGS percentage that applies to all products:

```
COGS = Net Revenue × (COGS Percentage / 100)
```

For example, if you set "10% of net revenue" and an order has $100 net revenue, COGS = $10.

### Option 3: Override per product

For products where Shopify data is missing or inaccurate, set custom COGS values in Upstack's product cost overrides.

## Contribution Margin Calculations

Upstack uses your configured costs to calculate contribution margins at four levels:

| Margin Level | Formula                                        |
| ------------ | ---------------------------------------------- |
| **CM1**      | Net Revenue − COGS                             |
| **CM2**      | CM1 − Fulfillment Costs (handling + shipping)  |
| **CM3**      | CM2 − Transaction Costs (gateway fees)         |
| **CM4**      | CM3 − Marketing Costs (ad spend + agency fees) |

<Tip>
  Higher contribution margin levels subtract more costs, giving you increasingly accurate views of true profitability.
</Tip>

## Related Metrics

Metrics powered by Upstack Costs:

| Category                                                                 | Metrics                                               |
| ------------------------------------------------------------------------ | ----------------------------------------------------- |
| **[COGS](/reference/metrics/orders/cogs)**                               | COGS, COGS per Order, COGS Rate                       |
| **[Fulfillment](/reference/metrics/orders/fulfillment)**                 | Handling Cost, Shipping Cost, Total Fulfillment       |
| **[Transaction](/reference/metrics/orders/transaction)**                 | Gateway Cost, Transaction Cost                        |
| **[Contribution Margin](/reference/metrics/orders/contribution-margin)** | CM1, CM2, CM3, CM4, Marketing Cost, Agency Fees, OPEX |
| **[Product Margin](/reference/metrics/orders/product-margin)**           | Gross Profit, Gross Profit %                          |

## Best Practices

<AccordionGroup>
  <Accordion title="Start with accurate COGS">
    Contribution margin calculations are only as good as your COGS data. Populate product costs in Shopify first, then use Upstack overrides for exceptions.
  </Accordion>

  <Accordion title="Review costs monthly">
    Fulfillment rates, gateway fees, and agency retainers can change. Set a monthly reminder to review and update your cost configuration.
  </Accordion>

  <Accordion title="Use realistic estimates">
    If you don't have exact costs, use conservative estimates. It's better to slightly overestimate costs than to show inflated margins.
  </Accordion>

  <Accordion title="Segment by customer type">
    Upstack calculates separate contribution margins for new vs. returning customers. This helps you understand acquisition profitability vs. retention profitability.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="COGS Metrics" icon="box" href="/reference/metrics/orders/cogs">
    Cost of goods sold metrics and formulas.
  </Card>

  <Card title="Contribution Margin" icon="chart-line" href="/reference/metrics/orders/contribution-margin">
    CM1 through CM4 metrics and calculations.
  </Card>

  <Card title="Fulfillment Costs" icon="truck" href="/reference/metrics/orders/fulfillment">
    Handling and shipping cost metrics.
  </Card>

  <Card title="Shopify Source" icon="shopify" href="/sources/shopify">
    How Upstack pulls COGS data from Shopify products.
  </Card>
</CardGroup>
