## Why Get an Ad Tracking Pixel and ClickURL?

You may find it desirable to retrieve the number of tracking clicks for a specific ad, enabling you to measure ad performance. This is especially useful for static text link ads (adTypeId 20) that cannot be normally served by JavaScript ad code or the Decision API.

The Get Ad Tracking Pixel and Click API call will return the `StaticClickUrl` for tracking clicks with the ad, in addition to an `ImpressionPixelUrl` for tracking impressions.

> 📘
>
> ### Note  
>
> Static text links no longer expire and will continue to be live.

The response for this API call returns an object containing the ad ID, the static click url, and the impression pixel URL.

> 🚧
>
> ### Caution  
>
> The requested ad must be fully distributed to Kevel's ad-delivery systems for a URL to be generated (we only allow URLs for fully published ads). If you receive a 404 error, retry your request after 10 seconds.
>
> If an ad is deactivated (`IsActive` is set to `false`), no impression or click URLs can be generated. You will receive the error `{"message":"This ad is not active."}` if you attempt to generate URLs for an inactive ad.

## API Syntax

When using the Get Ad Tracking Pixel and ClickURL API call, it is important to understand the syntax required to make the request. Because the Kevel API is a RESTful API, there is a specific request format that must be followed to ensure the endpoint can process the request. The format is:

`GET https://api.kevel.co/v1/ad/{AdID}/tracking-urls`

Where:

- `GET` \- the type of API request being made.
- `https://api.kevel.co` \- the URL for the request.
- `v1` \- the API version.
- `ad` \- the API endpoint being called.
- `AdID` \- the ID associated with the ad being called.
- `tracking-urls` \- the tracking URLs associated with the ad.

### Parameters

- **AdID**  
  int32  
  required  
  The ad ID (or creative flight map). Note that this is not the creative ID.

- **siteid**  
  int32  
  required  
  The site in your network where the impression and/or click should be tracked. The site must be eligible to serve the ad (i.e. the ad's flight belongs to a channel the site is associated with).

- **zoneid**  
  int32  
  An optional zone where the impression and/or click should be tracked. Must belong to the `siteid`.

- **keywords**  
  string  
  A comma separated string of keywords, like `foo,bar,baz`, that will be tracked in reporting with the click and/or impression. Keywords must not contain [disallowed characters defined in the keyword documentation.](https://dev.adzerk.com/docs/keyword-targeting#section-keywords-and-special-characters)

### Response Codes

- ``200      200``  
  object  
  ```
  Id
  integer
  Defaults to 0
  
  StaticClickUrl
  string
  
  ImpressionPixelUrl
  string
  ```

- ``400      400``

- ``404      404``

## Request Examples

### Requesting the ad for an eligible site:

```shell
curl -s -H "X-Adzerk-ApiKey:<API-KEY>" "https://api.kevel.co/v1/ad/123456/tracking-urls?siteid=123456"
```

### Requesting the ad for a site, zone, and keywords:

```shell
curl -s -H "X-Adzerk-ApiKey:<API-KEY>" "https://api.kevel.co/v1/ad/123456/tracking-urls?siteid=123456&zoneid=12345&keywords=foo,bar,baz"
```

### Example Response

```json
{
  "Id": 1234567,
  "StaticClickUrl": "https://e-1234.adzerk.net/r?e=eyJhdiI6MjMwNjIsImF0IjoyMCwiYnQiOjAsImNtIjo...&s=FOw8LAsm9ns2zM3THky6Dxvg0jc",
  "ImpressionPixelUrl": "https://e-1234.adzerk.net/p/eyJhdiI6MjMwNjIsImF0.../i.gif"
}
```
