# Key-Value Targeting

### General Information

Some networks support adding additional information to improve the ads for the current app context. Keywords can be defined like this:

{% tabs %}
{% tab title="Swift" %}
```swift
["interests": ["sports", "stocks"], "gender": ["female"]]
```
{% endtab %}

{% tab title="Objective-C" %}
```objectivec
@{@"interests": @[@"sports", @"stocks"], @"gender": @[@"female"]}
```
{% endtab %}
{% endtabs %}

{% hint style="info" %}
If you are using the [infeed banner placement](../../formats/banner/infeed-banner) or the [banner cache](../../formats/banner/banner-cache), then all targeting settings have to be configured for the used ad request object. The global or placement-specific settings described below will not be applied there.
{% endhint %}

Supported types of the keys: String.

Supported types for the values: String. Please contact the support team for help when defining targeting information.

{% hint style="info" %}
Setting the keyword targeting must be done after initializing AATKit.
{% endhint %}

### Set Global Targeting Keywords

To set the keyword targeting globally for all placements, you have to pass them to AATKit by calling the following method:

```swift
static func setTargetingInfo(info: [String: [String]])
```

**Usage**

{% tabs %}
{% tab title="Swift" %}
```swift
AATSDK.setTargetingInfo(info: ["interests": ["sports", "stocks"], "gender": ["female"]])
```
{% endtab %}

{% tab title="Objective-C" %}
```objectivec
[AATSDK setTargetingInfoWithInfo:@{@"interests": @[@"sports", @"stocks"], @"gender": @[@"female"]}];
```
{% endtab %}
{% endtabs %}

### Set Placement specific Keywords

Enables usage of keywords for specific placement in your application. The general setting of the targeting info will be overwritten for this placement.

**Usage**

{% tabs %}
{% tab title="Swift" %}
```swift
placement.targetingInfo = ["interests": ["sports", "stocks"], "gender": ["female"]]
```
{% endtab %}

{% tab title="Objective-C" %}
```objectivec
self.placement.targetingInfo = @{@"interests": @[@"sports", @"stocks"], @"gender": @[@"female"]};
```
{% endtab %}
{% endtabs %}

{% hint style="info" %}
The specified keywords are used for all networks by default. If you want to restrict keyword usage to only specific networks, you need to continue reading.
{% endhint %}

### Limit Ad Network specific Keywords

If you want to restrict keyword usage to specific ad networks, you have to use the following methods:

```swift
static func addAdNetworkForKeywordTargeting(network: AATAdNetwork)
```

Enables previously set keywords for a specific ad network only. When setting global and placement-specific keywords, the latter will take precedence.

Ad networks are specified using a value of the enumeration `AATAdNetwork`.

**Usage**

{% tabs %}
{% tab title="Swift" %}
```swift
AATSDK.addAdNetworkForKeywordTargeting(network: .ADMOB)
```
{% endtab %}

{% tab title="Objective-C" %}
```objectivec
[AATSDK addAdNetworkForKeywordTargetingWithNetwork:AATAdNetworkADMOB];
```
{% endtab %}
{% endtabs %}

You can also remove ad networks that were targeted before. The collection of ad network enumeration is a white list only. This means you cannot add networks to be excluded from keyword targeting.

```swift
static func removeAdNetworkForKeywordTargeting(network: AATAdNetwork)
```

**Usage**

{% tabs %}
{% tab title="Swift" %}
```swift
AATSDK.removeAdNetworkForKeywordTargeting(network: .ADMOB)
```
{% endtab %}

{% tab title="Objective-C" %}
```objectivec
[AATSDK removeAdNetworkForKeywordTargetingWithNetwork:AATAdNetworkADMOB];
```
{% endtab %}
{% endtabs %}
