# Google Ad Manager setup

## Ad Server Setup

On demand, we can handle the ad server setup, once you provided us with API access to GAM.

## Targeting Keys

Below, you'll find all targeting keys sent to Google Ad Manager:

```json
{
  "hb_env": "mobile-app",
  "hb_cache_id": "e18e97c5-dbba-416c-8df6-2c082b113f25",
  "hb_pb": "1.78",
  "hb_cache_path": "/cache",
  "hb_size": "320x480",
  "hb_bidder": "triplelift",
  "hb_partner": "nexx360",
  "hb_cache_host": "fast.nexx360.io",
  "hb_format": "banner"
}
```

### Targeting Keys Reference

| Key             | Description                      | Example                     |
| --------------- | -------------------------------- | --------------------------- |
| `hb_env`        | Environment identifier           | `mobile-app`                |
| `hb_cache_id`   | Unique cache ID for ad retrieval | UUID                        |
| `hb_pb`         | Price bucket                     | `1.78`                      |
| `hb_cache_path` | Cache endpoint path              | `/cache`                    |
| `hb_cache_host` | Cache host domain                | `fast.nexx360.io`           |
| `hb_size`       | Ad dimensions                    | `320x480`, `300x250`        |
| `hb_bidder`     | Winning SSP/bidder               | `triplelift`, `appnexus`    |
| `hb_partner`    | Partner identifier               | `nexx360`                   |
| `hb_format`     | Ad format type                   | `banner`, `video`, `native` |

{% hint style="info" %}
`hb_partner` can be used to ensure proper line item allocation for Nexx360 bids.
{% endhint %}

## Line Item Setup

### Recommended Line Item Structure

1. **Key-Value Targeting**: Target `hb_partner` = `nexx360` and `hb_pb` for price buckets
2. **Creative Size**: Use fluid or specific sizes matching your ad units
3. **Priority**: Set appropriate priority based on your yield strategy

### Price Bucket Ranges

With `dense` granularity (default), price buckets are configured as follows:

| Range          | Increment |
| -------------- | --------- |
| $0.00 - $3.00  | $0.01     |
| $3.00 - $8.00  | $0.05     |
| $8.00 - $20.00 | $0.50     |
| $20.00+        | $1.00     |

## Granularity

By default, Granularity for inapp is set to `dense`. Please contact us if you need a custom granularity.

## Creative

As per Prebid documentation, you need to use the following creative (which includes mobileResize for proper ad rendering):

```html
<script src="https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/creative.js"></script>
<script>
  var ucTagData = {};
  ucTagData.adServerDomain = "";
  ucTagData.pubUrl = "%%PATTERN:url%%";
  ucTagData.adId = "%%PATTERN:hb_adid%%";
  ucTagData.cacheHost = "%%PATTERN:hb_cache_host%%";
  ucTagData.cachePath = "%%PATTERN:hb_cache_path%%";
  ucTagData.uuid = "%%PATTERN:hb_cache_id%%";
  ucTagData.mediaType = "%%PATTERN:hb_format%%";
  ucTagData.env = "%%PATTERN:hb_env%%";
  ucTagData.size = "%%PATTERN:hb_size%%";
  ucTagData.hbPb = "%%PATTERN:hb_pb%%";
  ucTagData.mobileResize = "hb_size:%%PATTERN:hb_size%%";

  try {
    ucTag.renderAd(document, ucTagData);
  } catch (e) {
    console.log(e);
  }
</script>
```

{% hint style="warning" %}
The `mobileResize` parameter is essential for proper ad sizing on mobile devices. Do not remove it.
{% endhint %}

## Video Creative

For video line items, use the following VAST redirect creative:

```
https://%%PATTERN:hb_cache_host%%%%PATTERN:hb_cache_path%%?uuid=%%PATTERN:hb_cache_id%%
```

## Cache URL

The ad creative is retrieved from the Nexx360 cache using the following URL pattern:

```
https://{hb_cache_host}{hb_cache_path}?uuid={hb_cache_id}
```

Example:

```
https://fast.nexx360.io/cache?uuid=e18e97c5-dbba-416c-8df6-2c082b113f25
```
