# Line Item Setup

This page explains how Nexx360 line items are structured in Google Ad Manager (GAM) and how they match bids from n360ortb.

## Order Structure

When you [connect your GAM account](/integration-methods/direct-integration-n360ortb/gam-integration/connect-your-gam-account.md), Nexx360 creates the following structure:

```
Order: "Nexx360 - Direct Integration"
├── Line Item: n360_pb = 0.05
├── Line Item: n360_pb = 0.10
├── Line Item: n360_pb = 0.15
├── ...
├── Line Item: n360_pb = 5.00
├── Line Item: n360_pb = 5.10
├── ...
├── Line Item: n360_pb = 10.00
├── Line Item: n360_pb = 10.50
├── ...
└── Line Item: n360_pb = 20.00
```

Each line item targets a specific price bucket value and competes in the GAM unified auction at that price.

## Line Item Configuration

Each line item is configured as follows:

| Setting      | Value                                                                                                                                                              |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Type**     | Price Priority                                                                                                                                                     |
| **Rate**     | CPM matching the `n360_pb` value                                                                                                                                   |
| **Creative** | Third-party creative using n360ortb display library ([see creative setup](/integration-methods/direct-integration-n360ortb/gam-integration/gam-creative-setup.md)) |
| **Sizes**    | All sizes configured for your inventory                                                                                                                            |

### Key-Value Targeting

Every line item targets the `n360_pb` key with its corresponding price bucket value:

| Key       | Operator | Value                               |
| --------- | -------- | ----------------------------------- |
| `n360_pb` | is       | *(price bucket value, e.g. `2.50`)* |

This ensures the correct line item wins in the GAM auction based on the bid price sent by n360ortb.

## Currency

Line item CPMs are created in the currency configured during initialization:

```javascript
n360ortb.init({
  currency: 'EUR'  // 'EUR', 'USD', or 'GBP'
});
```

The currency setting controls:

1. **Bid request** — sent in the OpenRTB `cur` field (e.g., `"cur": ["EUR"]`), so SSPs return bids in that currency
2. **Price buckets** — the `n360_pb` values are in the configured currency
3. **Line item CPMs** — must match the same currency in GAM

| `currency` | Bid prices in  | Line item CPMs in | Example `n360_pb` |
| ---------- | -------------- | ----------------- | ----------------- |
| `'EUR'`    | Euros          | Euros             | `2.50` = 2.50 EUR |
| `'USD'`    | US Dollars     | US Dollars        | `2.50` = 2.50 USD |
| `'GBP'`    | British Pounds | British Pounds    | `2.50` = 2.50 GBP |

The default currency is `USD` if not specified.

{% hint style="warning" %}
The currency configured in n360ortb **must match** the currency used for your GAM line item CPMs. A mismatch will cause bids to compete at the wrong price in the unified auction.
{% endhint %}

## Price Granularity

n360ortb uses **medium granularity** (same as Prebid.js medium granularity) to bucket bid prices into discrete values. This determines the set of line items created in GAM.

### Price Bucket Ranges

| Price Range     | Increment | Number of Line Items | Example Values                                   |
| --------------- | --------- | -------------------- | ------------------------------------------------ |
| $0.01 - $5.00   | $0.05     | 100                  | `0.05`, `0.10`, `0.15`, ..., `4.95`, `5.00`      |
| $5.01 - $10.00  | $0.10     | 50                   | `5.10`, `5.20`, `5.30`, ..., `9.90`, `10.00`     |
| $10.01 - $20.00 | $0.50     | 20                   | `10.50`, `11.00`, `11.50`, ..., `19.50`, `20.00` |

**Total: \~170 line items**

**Price cap:** Bids above $20.00 are capped at `20.00`.

### How Bucketing Works

The bid price is rounded **down** to the nearest increment:

| Actual Bid Price | Price Bucket (`n360_pb`) | Line Item CPM |
| ---------------- | ------------------------ | ------------- |
| $0.03            | `0.00`                   | $0.00         |
| $1.27            | `1.25`                   | $1.25         |
| $2.50            | `2.50`                   | $2.50         |
| $4.99            | `4.95`                   | $4.95         |
| $5.43            | `5.40`                   | $5.40         |
| $7.89            | `7.80`                   | $7.80         |
| $12.30           | `12.00`                  | $12.00        |
| $15.75           | `15.50`                  | $15.50        |
| $25.00           | `20.00`                  | $20.00        |

{% hint style="info" %}
Medium granularity provides a good balance between auction accuracy and the number of line items to manage in GAM. Finer granularity would require thousands of line items, while coarser granularity would reduce bid competitiveness.
{% endhint %}

## Example Targeting Sent to GAM

When `n360ortb.setDisplayBids()` is called, the following key-value pairs are set on each GPT slot that received a bid:

### Example: 300x250 bid at $2.50 CPM

```json
{
  "n360_bid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "n360_pb": "2.50",
  "n360_sz": "300x250",
  "n360_crid": "creative_12345",
  "n360_ssp": "appnexus"
}
```

### Example: 728x90 bid at $0.87 CPM

```json
{
  "n360_bid": "f9e8d7c6-b5a4-3210-fedc-ba9876543210",
  "n360_pb": "0.85",
  "n360_sz": "728x90",
  "n360_crid": "creative_67890",
  "n360_ssp": "rubicon"
}
```

Note that the actual bid was $0.87 but `n360_pb` is `0.85` (rounded down to the nearest $0.05 increment).

### Targeting Keys Reference

| Key         | Description               | Used By                                               |
| ----------- | ------------------------- | ----------------------------------------------------- |
| `n360_bid`  | Unique bid identifier     | Creative template (to fetch the ad markup)            |
| `n360_pb`   | Price bucket value        | Line item targeting (to select the correct line item) |
| `n360_sz`   | Ad size (e.g., `300x250`) | Creative sizing                                       |
| `n360_crid` | Creative ID from the SSP  | Reporting and debugging                               |
| `n360_ssp`  | SSP/bidder that won       | Reporting and debugging                               |

{% hint style="warning" %}
Only `n360_bid` and `n360_pb` are always present. The keys `n360_sz`, `n360_crid`, and `n360_ssp` are included only when available in the bid response.
{% endhint %}

## How It All Fits Together

Here is the end-to-end flow from bid request to ad rendering:

1. **n360ortb.fetchBids()** sends an OpenRTB request and receives bid responses
2. The winning bid price (e.g., $2.53) is bucketed to `2.50`
3. **n360ortb.setDisplayBids()** sets `n360_pb=2.50` (and other keys) on the GPT slot
4. **googletag.pubads().refresh()** triggers the GAM auction
5. GAM matches the `n360_pb=2.50` line item, which competes at $2.50 CPM
6. If the Nexx360 line item wins, GAM renders the [creative template](/integration-methods/direct-integration-n360ortb/gam-integration/gam-creative-setup.md)
7. The creative uses `n360_bid` to fetch and display the ad from Nexx360

## Verifying Targeting in Browser

To inspect the targeting values being set on GPT slots:

1. Open your browser developer tools (F12)
2. In the Console, run:

```javascript
googletag.pubads().getSlots().forEach(function(slot) {
  console.log(slot.getSlotElementId(), {
    n360_bid: slot.getTargeting('n360_bid'),
    n360_pb: slot.getTargeting('n360_pb'),
    n360_sz: slot.getTargeting('n360_sz'),
    n360_crid: slot.getTargeting('n360_crid'),
    n360_ssp: slot.getTargeting('n360_ssp')
  });
});
```

Or enable [debug mode](/integration-methods/direct-integration-n360ortb/api-reference.md) by adding `?n360debug` to the page URL to see targeting in the console logs automatically.

## Next Steps

* [GAM Creative Setup](/integration-methods/direct-integration-n360ortb/gam-integration/gam-creative-setup.md) - How the creative template renders winning bids
* [Connect your GAM Account](/integration-methods/direct-integration-n360ortb/gam-integration/connect-your-gam-account.md) - Grant Nexx360 access to create line items
* [GAM Integration Example](/integration-methods/direct-integration-n360ortb/gam-integration.md) - Complete integration code


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.nexx360.io/integration-methods/direct-integration-n360ortb/gam-integration/line-item-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
