---
title: "Click Macros"
canonical: "https://hub.freewheel.tv/space/BC/114688403/Click%20Macros"
format: markdown
---
> Macro (column)
> 
> |  |
> | --- |
> | #### Table of Contents<br>> Macro (toc) |

---

# Overview

This article explains how to track clicks when using third-party JavaScript ad tags or HTML5 creatives. It does not apply to ads uploaded directly into Buyer Cloud or through a VAST 2.0 Wrapper, because Buyer Cloud automatically handles click redirection in those cases.

In third-party ad tags, a click macro must be included to track clicks and properly redirect the user to the destination URL. The API and UI automatically detect tags from popular ad serving systems such as DoubleClick Campaign Manager and Sizmek.

For proper click tracking with Innovid, additional settings must be enabled by the Innovid team. 

---

# How Click Tracking Works

When using Buyer Cloud for click tracking, the `{{CLICK_URL}}` macro is used to generate a URL that includes both the Buyer Cloud click tracker and the Buyer Cloud redirect. This URL will have the following structure:

##### **vbnet**

```
 https://event.bidr.io/clk?dest=<destination_url>
```

- The **destination URL** must be properly encoded (escaped) for the redirect to work correctly.
- If the ad is served through an exchange that requires a redirect, the destination URL must be encoded twice.

**Example 1**:  
To properly encode a destination URL, use this format:

##### **perl**

```
 {{CLICK_URL}}https%3A%2F%2Fwww.beeswax.com%2Fprivacy.html
```

Some exchanges require additional redirects, which means the destination URL will need to be escaped a second time.

**Example 2**:  
If the exchange requires an extra redirect, the destination URL will need to be encoded twice:

##### **perl**

```
 {{CLICK_URL}}https%253A%252F%252Fwww.beeswax.com%252Fprivacy.html
```

Buyer Cloud also provides an **escaped click macro**: `{{CLICK_URL_ESC}}`. This is typically used when the ad server performs an initial redirect before redirecting through the platform. In this case, the destination URL must be encoded twice or even three times, depending on the exchange's requirements.

**Example 3**:  
For a redirect through an ad server, the URL should be encoded twice:

##### **perl**

```
 {{CLICK_URL_ESC}}https%253A%252F%252Fwww.beeswax.com%252Fprivacy.html
```


**Example 4**:  
If the exchange requires additional redirects, encode the destination URL three times:

##### **perl**

```
 {{CLICK_URL_ESC}}https%25253A%25252F%25252Fwww.beeswax.com%25252Fprivacy.html
```

---

# Configuring Click Macros in Ad Servers

When using a third-party ad server, the `{{CLICK_URL}}` or `{{CLICK_URL_ESC}}` macro is inserted into the appropriate parameter of the ad server's tag. The destination URL is declared within the ad server as well.

Ad servers handle URL encoding in different ways:

1. **Some ad servers handle URL encoding automatically** without any extra work needed.
2. **Other ad servers require you to specify how many times the URL should be encoded**. For example, you might need to specify whether the destination URL should be encoded once or twice.
3. **Some ad servers do not offer URL encoding parameters**, and you will need to manually encode the destination URL using a custom "for" loop.
4. **Certain ad servers fire click trackers in parallel**, which means you will not need to escape the URL at all. In this case, you only need to insert the Buyer Cloud click macro without additional encoding.

To determine how many times to escape the destination URL, use the `{{NUM_DEST_URL_ESCAPES}}` macro (which can be set to 1 or 2) or the `{{NUM_DEST_URL_ESC_ESCAPES}}` macro (which can be set to 2 or 3).

Typically:

- `{{NUM_DEST_URL_ESCAPES}}` is used with the `{{CLICK_URL}}` macro.
- `{{NUM_DEST_URL_ESC_ESCAPES}}` is used with the `{{CLICK_URL_ESC}}` macro.

> ⚠️ It is important to test different combinations of these macros, as there is no one-size-fits-all approach.


---

# Examples of Click Tracking

Here are some scenarios to demonstrate how click tracking works with different ad servers and redirects.

#### 1. Using the `{{CLICK_URL}}` Macro without an Ad Server

1. **Before the ad is served**: The Buyer Cloud click macro expands to a URL with the domain [https://event.bidr.io/](https://event.bidr.io/).
2. **User clicks on the ad**:
  - If the exchange does not require a redirect, the user is sent:
    - First, through the click tracker ([https://event.bidr.io/clk](https://event.bidr.io/clk)).
    - Then, to the destination URL, which must be encoded once.
  - If the exchange requires a redirect, the user is sent:
    - First, through the click tracker ([https://event.bidr.io/clk](https://event.bidr.io/clk)).
    - Then, through the exchange.
    - Finally, to the destination URL, which must be encoded twice.

#### 2. Using the `{{CLICK_URL_ESC}}` Macro with an Ad Server that Redirects First

1. **Before the ad is served**: The Buyer Cloud click macro (`{{CLICK_URL_ESC}}`) expands to an escaped Buyer Cloud URL.
2. **User clicks on the ad**:
  - If the exchange does not require a redirect, the user is sent:
    - First, through the ad server.
    - Then, to the click tracker (which is escaped once).
    - Finally, to the destination URL (which is escaped twice).
  - If the exchange requires a redirect, the user is sent:
    - First, through the ad server.
    - Then, to the click tracker (escaped once).
    - Next, through the exchange (escaped twice).
    - Finally, to the destination URL (escaped three times).

#### 3. Using the `{{CLICK_URL_ESC}}` Macro with an Ad Server that Fires Click Trackers in Parallel (e.g., Sizmek)

1. **Before the ad is served**: The Buyer Cloud click macro (`{{CLICK_URL_ESC}}`) expands to an escaped Buyer Cloud URL.
2. **User clicks on the ad**:
  - If the exchange does not require a redirect, the user is sent directly to the destination URL.
  - In parallel, a click tracker fires from the Buyer Cloud domain.
  - If the exchange requires a redirect, the user is sent directly to the destination URL, while the click tracker fires in parallel, and an additional redirect happens through the exchange.

---

# Implementing the Buyer Cloud Click Macro in Innovid (Formerly Flashtalking) Tags

<span style="color: #172b4d">To ensure clicks track properly in both Innovid and reporting, Buyer Cloud click macros must be inserted into the ad tag, and Innovid must properly configure URL-encoding logic.</span>

## Required Steps

1. Using the Beeswax site within Innovid automatically inserts the required macros into tags.
2. Insert macro into **Third Party Click (ftClick)** within **Data Pass Macros**.
3. Insert into **Publisher Click ID (pub_click)** within **Data Pass Macros**.
4. Innovid adds a function to **encode the destination URL once by default**, and **twice if pub_click value equals "2"**.
5. Innovid **disables Third Party Click decoding**, as Innovid normally decodes URLs inserted into ftClick, which can cause errors on exchanges that add an additional redirect.

Steps 4 and 5 above require submitting a request to the Flashtalking team.

For any questions on this process or to verify that it’s been done correctly, please reach out to [Support](mailto:support@beeswax.com).