## Overview  
Kevel's "Excluding Ads Based on Past Behavior" capability refers to tracking a user's click/conversion behavior and blocking any ads from the same flight/advertiser in the future.

For instance, if a user clicks on an ad for Breyers Ice Cream, in the future you could prevent the user from seeing the same ad from Breyers again.

## UserDB UserKeys  
Kevel stores a user's past behavior data in UserDB, a data management platform for recording 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.

## Enabling the Exclusion of Ads Based on Behavior  
**1. Enabling via UI**  
1. In Flight settings, go to the Behavioral Targeting tab  
2. The first two rows allow you to toggle whether to stop showing the user ads from a flight/advertiser based on whether they click/convert

> 📘  
> Checking **Clicks** is the exact same as checking both **Clicks** and **Converts**.  
> **Converts** option only works with Javascript and Server to Server conversions. It does not work with custom event conversions (event ids 1, 2, 3).

**2. Enabling via the API**  
You'll want to use the `BehavioralTargeting` object in the [Create Flight](https://dev.kevel.co/v1.0/reference/flight#create-flight) endpoint.

Within that are two other objects: `onClick` and `onConvert`. These refer to whether you want to exclude future ads based on whether they clicked, or both clicked and converted (ex: made a purchase).

Within those are two additional fields: `stopShowingAdsFromFlight` and `stopShowingAdsFromAdvertiser`. These refer to whether you want the user to no longer see an ad from that specific Flight, or from the Advertiser as a whole.

For example, here's enabling it on click and excluding ads at the Flight level:

```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": {
      "stopShowingAdsFromFlight": true
    }
  }
}
```

And here's an example for enabling it on conversions and excluding at the Advertiser level:

```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": {
      "stopShowingAdsFromAdvertiser": true
    }
  }
}
```

Once you enable it at the Flight level, UserDB will automatically update a user's UserDB record to indicate they clicked/converted on the specific ad. Depending on your rules, that particular Ad/Advertiser may be excluded from consideration in future request from that user.

> 🚧  
> Remember: for this to work, you will need to pass the UserKey in the `user` object's `key` field of the Decision API request. If you send the UserKey, Kevel's Ad Decision Engine will cross-reference with UserDB when picking the right ad. If you do not send UserKeys, any user-level targeting will not work.
