<!-- https://docs.youtarget.com/advertiser/en/reference/macros.html -->

# Macros

> Which values are inserted into the campaign and creative link on click, in what format, and when a macro stays empty.

A macro is a word in curly braces in a link, for example `{click_id}`. When a user clicks an ad, the platform replaces the macro with a value and only then opens your page. This is how the click ID, campaign ID, source ID and device data get into your tracker or analytics.

## Where to use them

Macros work in two fields:

- **Target URL** in the campaign settings;
- the landing page field in a creative: **Target URL:** for native, Push and Pop creatives, **Landing page:** for banners and video creatives. If the creative has **Matches URL in advertising campaign settings** selected (**Matches URL in campaign settings** for banners and video), the campaign link is used.

Under each of these fields there is an **Available macros** list. Clicking a macro inserts it into the field.

## Macro list

| Macro | What is inserted | Example value | When empty |
| --- | --- | --- | --- |
| `{click_id}` | Click ID: a unique 36-character string. The tracker returns the same string in the [postback](https://docs.youtarget.com/advertiser/en/glossary/postback.md) | `3f1c9a2e-5b7d-4c1a-9e2f-0a1b2c3d4e5f` | Always filled |
| `{campaign}` | Campaign ID | `1038` | Always filled |
| `{creative}` | Creative ID | `7712` | Always filled |
| `{zone_id}` | Where the impression was served: the traffic source ID and the ID of the ad slot within that source, separated by a colon. The value is URL-encoded, so the colon is passed as `%3A` | `1201%3Aa7f3c9` | The ad slot ID can be empty: `1201%3A` |
| `{cpc}` | Cost per click in your account currency, four decimal places. For Pop with pay per impression: the price of one impression | `0.0500` | With pay per impression (CPM) in all formats except Pop |
| `{language}` | User language: two lowercase Latin letters | `de` | The language was not detected |
| `{device}` | Device type: `mobile`, `tablet`, `pc`, `ctv` (Smart TV) or `bot` | `mobile` | The type was not detected |
| `{browser}` | Browser: `Chrome`, `ChromeMobile`, `Safari`, `Firefox`, `Edge`, `Opera`, `YandexBrowser`, `SamsungInternet` and others | `ChromeMobile` | The browser was not detected |
| `{platform}` | Operating system: `android`, `ios`, `windows`, `macos`, `linux` or `symbian` | `android` | The OS was not detected |
| `{random}` | A random 8-character string: Latin letters, digits, `_` and `-`. New on every click. Helps bypass the tracker cache. The **Available macros** list labels it "Generation of a random number", but the value is a string | `aZ3_kP9x` | Always filled |
| `{sub_age}` | Push only: how many days ago the user subscribed to notifications | `12` | `0` if the source did not pass the subscription age or the format is not Push |

The `{sub_age}` macro appears in the **Available macros** list only for Push campaigns and Push creatives.

## Example

The link in the **Target URL** field:

```text
https://example.com/sale?click_id={click_id}&campaign={campaign}&source={zone_id}&os={platform}
```

What your site receives after a click:

```text
https://example.com/sale?click_id=3f1c9a2e-5b7d-4c1a-9e2f-0a1b2c3d4e5f&campaign=1038&source=1201%3Aa7f3c9&os=android
```

## Rules

- **Write the macro exactly as in the list.** Case matters: `{Click_ID}` is not replaced. An unknown macro, for example one with a typo, stays in the link as is.
- **Put macros in parameter values** after `?` and `&`, as in the example. Values other than `{zone_id}` and `{language}` are inserted without encoding.
- **You need `{click_id}` to track conversions.** The tracker must store it and return it unchanged in the postback. A conversion counts if it arrives no later than 60 days after the click. For details, see [Set up postback and conversion tracking](../cases/postback.md).
- **You do not need platform macros in the postback link.** Your tracker fills it in with its own macros.
