### Check out our [UserDB Interest Quickstart](https://dev.kevel.co/v1.0/docs/userdb-tutorial) to see how to get this tested quickly

### Preferred Method: Segment Targeting

[Segment targeting](https://dev.kevel.com/docs/segment-targeting) using [Kevel Audience](https://docs.audience.kevel.com/) or a synced external system (like a CDP) is the recommended approach for targeting interest and behavioral user groups. It enables centralized audience management, simplifies campaign setup, and scales cleanly across use cases.

## Overview

With Interest Targeting, you could let Advertisers target specific interest-based segments (and charge a premium for doing so). Such as:

| Segment | Description |
| --- | --- |
| Sport Lovers | People who have engaged with sports content (either organic or paid ad) |
| Affluent Customers | People whose behavior indicates high income bracket (searches for expensive homes, etc) |
| Any custom segment you can build based on either user-given or behavior-based info |  |

### To help with terminology on this page:

(1) **`[Flight Categories](https://dev.kevel.co/v1.0/reference/flight-categories-1#create-flight-categories)'** or **`categories`** = the interests you want to target. (2) **`interests`** = the UserDB name for a category

## UserDB UserKeys

Kevel saves a user's interests in UserDB, a data management platform for storing user-level data (more info [here](https://dev.kevel.co/v1.0/docs/userdb-1)). All data is tied to a UserKey, which is the persistent `key` field in UserDB, and is located in the `interests` field in UserDB.

## Creating Interest Categories

Interests (or Flight Categories) are created during the Flight creation process, or by pinging the [Create Flight Categories endpoint](https://dev.kevel.co/v1.0/reference/flight-categories-1#create-flight-categories).

## Add a User to an Interest Category

This happens in one of two ways:

| Method |
| --- |
| (1) Using behavioral ad tracking. Here, Kevel adds users to Interest Segments based on what type of ad they interact with |
| (2) Pinging UserDB directly. Learn more [here](https://dev.kevel.co/v1.0/reference/userdb#add-interest-to-user). |

## Setting Up Behavioral Tracking - API

Many clients create Interest Segments by tying an Interest to a specific Flight and then, when a user clicks/converts on an Ad from that Flight, automatically updating the user's UserDB record to indicate he/she should be in that segment.

For instance, if you are showing ads for the NBA, if a user clicks on those ads, that user could be added to the "Sports Fan" interest category.

To do this, you need to first [Create a Flight](https://dev.kevel.co/v1.0/reference/flight#create-flight) with Interest Tracking enabled and THEN map an Interest to it (using the Flight's ID from the Create Flight Response).

**1. [Create a Flight](https://dev.kevel.co/v1.0/reference/flight#create-flight) And Enable Tracking**

You'll use the `BehavioralTargeting` object in the [Create Flight](https://dev.kevel.co/v1.0/reference/flight#create-flight) or [Update Flight](https://dev.kevel.co/v1.0/reference/flight#update-flights) endpoint to enable Interest Tracking.

Within that are two other objects: `onClick` and `onConvert`. These refer to whether you want to add an Interest to a user based on whether they clicked on the ad, or both clicked AND converted (ex: made a purchase).

Then, you'll want to mark the boolean field of `storeCategoriesFromFlightAsInterest` as `true` for `onClick` or `onConvert`.

For example, here's enabling it on click:

```json
{
  "Name":"Nike Christmas Flight - iPhones",
  "StartDateISO":"2017-05-01T00:00:00.00.0000000",
  "EndDateISO":"2017-12-31T00:00:00.00.0000000",
  "CampaignId":1234,
  "PriorityId":1234,
  "GoalType": 1,
  "BehavioralTargeting": {
    "onClick": {
      "storeCategoriesFromFlightAsInterest": true
    }
  }
}
```

Here's enabling it on Conversion:

```json
{
  "Name":"Nike Christmas Flight - iPhones",
  "StartDateISO":"2017-05-01T00:00:00.00.0000000",
  "EndDateISO":"2017-12-31T00:00:00.00.0000000",
  "CampaignId":1234,
  "PriorityId":1234,
  "GoalType": 1,
  "BehavioralTargeting": {
    "onConvert": {
      "storeCategoriesFromFlightAsInterest": true
    }
  }
}
```

**2. Create and Map an Interest to a Flight**

Once the Flight is created, store the `id` in the Response. This is the Flight's ID.

Then, you'll use the [Create Flight Categories](https://dev.kevel.co/v1.0/reference/flight-categories-1#create-flight-categories) endpoint to add an Interest to the Flight. If the Interest isn't already created in Kevel, it will create it.

```json
{
  "Id":123456,
  "Name":"Sports"
}
```

`id` here is the Flight's ID. Pinging this endpoint will add the Interest to the Flight.

## How To Target An Interest Segment

An Interest Segment refers to all the users who are now associated with a specific Interest, either through behavioral click tracking or directly updating UserDB.

You can target this segment with either the UI or API. It requires the use of [Custom Targeting](https://dev.kevel.co/v1.0/docs/custom-targeting), [UserDB Reserved Keys](https://dev.kevel.co/docs/reserved-keys#section-user), and [Zerkel Queries](https://dev.kevel.co/v1.0/docs/zerkel-queries).

| UserDB Interest Category | Example Custom Targeting Query |
| --- | --- |
| Sport Lovers | $user.interests contains "Sport Lovers" |
| Affluent Customers | $user.interests contains "Affluent" |

Here's an example [Create Flight](https://dev.kevel.co/v1.0/reference/flight#create-flight) API request to set-up a Flight targeting the "Sport Lovers" interest:

```json
{
  "CampaignId":1234,
  "PriorityId":1325,
  "Name":"Adidas - New Basketball Shoes",
  "StartDateISO":"2017-05-01T00:00:00.00.0000000",
  "GoalType": 1,
  "CustomTargeting":"$user.interests CONTAINS \"Sports Lovers\""
}
```

In this example, Kevel's Ad Decision Engine will show an Ad from this Flight ONLY if the user's UserDB record shows them tied to the "Sports" interest.

## Reporting on Interests

Kevel's reporting does not break down custom targeting. However, you could create Flights that target just one category, which will let you see the performance that way.
