# Macros

Before returning the bid response, the DSP replaces macros in the creative's ad markup (`adm`). This allows dynamic values to be injected at serve time.

## Available macros

| Macro                | Description                                       | Example value               |
| -------------------- | ------------------------------------------------- | --------------------------- |
| `${GDPR}`            | GDPR applies flag                                 | `0` or `1`                  |
| `${GDPR_CONSENT}`    | IAB consent string                                | `CPhdLUAPhdLUA...`          |
| `${GDPR_CONSENT_39}` | IAB consent string (any numeric suffix)           | `CPhdLUAPhdLUA...`          |
| `${ADDTL_CONSENT}`   | Additional consent providers                      | Provider string             |
| `${REFERRER}`        | Page URL or app store URL (URL-encoded)           | `https%3A%2F%2Fexample.com` |
| `${FIRSTID}`         | First-party ID from `user.ext.eids` (URL-encoded) | User ID string              |
| `${CACHEBUSTER}`     | Random UUID for cache busting                     | `a1b2c3d4-...`              |
| `${LINEITEMID}`      | Line item ID                                      | `12345`                     |
| `[timestamp]`        | Current time in milliseconds                      | `1712678400000`             |

## Click tracking

The DSP automatically injects click tracking into ad markup. The behavior depends on the creative configuration:

### When `clickUrl` is set

The `clickUrl` value in the ad markup is replaced with a tracking URL that redirects to the original destination:

```
https://fast.nexx360.io/track-click?redirect_url=<original>&tag_id=...&lid=...&crid=...
```

### When `${CLICK_URL}` or `${CLICK_URL_ENC}` macros are present

These macros are used for third-party ad creatives:

| Macro              | Description                                                            |
| ------------------ | ---------------------------------------------------------------------- |
| `${CLICK_URL}`     | Replaced with the tracking URL (prepended to the third-party redirect) |
| `${CLICK_URL_ENC}` | Replaced with the URL-encoded tracking URL                             |

### Auto-tracking (no clickUrl, no macros)

When no explicit click URL or macro is defined:

* **Banner**: `<a href="...">` tags are automatically wrapped with click tracking
* **Video (VAST)**: A `<ClickTracking>` element is injected inside `<VideoClicks>`

## Click tracking parameters

The tracking URL includes these parameters for reporting:

| Parameter      | Description                    |
| -------------- | ------------------------------ |
| `redirect_url` | Original click destination     |
| `tag_id`       | Impression tag ID              |
| `lid`          | Line item ID                   |
| `crid`         | Creative ID                    |
| `deal_id`      | Deal external ID               |
| `adomain`      | Advertiser domain              |
| `country`      | User country                   |
| `area`         | Deployment region              |
| `consent`      | GDPR consent flag              |
| `mediatype`    | Creative media type            |
| `sid`          | Split ID (if applicable)       |
| `segment_id`   | CPC segment ID (if applicable) |
| `cookie`       | Cookie-based user flag         |
| `domain`       | Publisher domain               |
| `gpid`         | Global placement ID            |


---

# 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/campaign-delivery/macros.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.
