> ## 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.

# Agency Fees: Marketing Agency Costs

> Track agency fees for your Shopify store. Understand total marketing agency costs deducted from contribution margin.

<Tip>
  Agency Fees tracks user-defined agency costs from order cost entries. These fees are deducted from CM3 to calculate CM4.
</Tip>

## Formula

<Info>
  **Agency Fees** = **SUM** ( Order Cost Entries ) **WHERE** category = Agency Fees
</Info>

### Formula Components

| Metric                     | Definition                                             |
| -------------------------- | ------------------------------------------------------ |
| **Order Cost Entries**     | User-defined costs configured in Upstack Cost Settings |
| **category = Agency Fees** | Filters to costs categorized as agency fees            |

| Metadata        |                                         |
| --------------- | --------------------------------------- |
| **Type**        | Currency                                |
| **Data Source** | [Upstack Costs](/sources/upstack-costs) |
| **Aggregation** | Sum                                     |

***

## Example

Your Shopify store has **\$15,000** in agency fees configured across **500 orders**.

| Metric                | Value    | Calculation                |
| --------------------- | -------- | -------------------------- |
| Total Orders          | 500      | All orders in period       |
| Agency Fees           | \$15,000 | Sum of agency cost entries |
| Agency Fees Per Order | \$30.00  | \$15,000 ÷ 500             |

Agency fees represent the costs of external marketing agencies and consultants that manage your advertising.

***

## How It Works

Agency Fees are pulled from cost entries you configure in Upstack Cost Settings. They can be set as flat fees per order, percentage of revenue, or fixed monthly amounts allocated across orders. These costs are deducted after CM3 to calculate CM4.

***

## When to Use

| Scenario                      | Action                                      |
| ----------------------------- | ------------------------------------------- |
| Full profitability analysis   | Include agency fees in contribution margin  |
| Agency ROI evaluation         | Compare agency costs to incremental revenue |
| Cost structure planning       | Understand agency impact on margins         |
| In-house vs agency comparison | Model cost differences                      |

***

## Related Metrics

| Metric                                                                                         | Relationship                              |
| ---------------------------------------------------------------------------------------------- | ----------------------------------------- |
| [NC Agency Fees](/reference/metrics/orders/contribution-margin/new-customer-agency-fees)       | Agency fees for new customer orders       |
| [RC Agency Fees](/reference/metrics/orders/contribution-margin/returning-customer-agency-fees) | Agency fees for returning customer orders |
| [Opex](/reference/metrics/orders/contribution-margin/opex)                                     | Operating expenses, also deducted for CM4 |
| [Marketing Cost](/reference/metrics/orders/contribution-margin/marketing-cost)                 | Other marketing costs                     |

[See all Contribution Margin metrics →](/reference/metrics/orders/contribution-margin)
