> ## Documentation Index
> Fetch the complete documentation index at: https://docs.adrop.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Targeting Settings

> Learn how to set up targeting in the React Native SDK.

## Overview

Targeting settings allow you to show personalized ads to specific user groups. The Adrop SDK provides **audience targeting**.

* **Audience Targeting**: Display ads based on user attributes (properties).

<Note>
  To collect targeting data, you must set properties before loading ads.
</Note>

***

## UID Setup (Optional)

Set a user identifier (UID) to share targeting data across platforms. UID is optional and is not required for property-based or event-based targeting.

### Usage

```typescript theme={null}
import { Adrop } from 'adrop-ads-react-native'

// After user login (optional)
Adrop.setUID("user_123")

// On user logout
Adrop.setUID("")
```

### Parameters

| Parameter | Type     | Description                                      |
| --------- | -------- | ------------------------------------------------ |
| `uid`     | `string` | Unique user identifier (e.g., service member ID) |

<Warning>
  UID is transmitted hashed with SHA-256. Do not pass personal information (email, phone number, etc.) directly.
</Warning>

<Note>
  Pass an empty string (`""`) on logout to reset the UID.
</Note>

***

## Audience Targeting

Collect user attribute information (properties) to show ads to specific user groups.

### Setting Properties

Use the `AdropMetrics.setProperty()` method to collect user attribute information.

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'

// String property
AdropMetrics.setProperty("membership_level", "premium")

// Number property
AdropMetrics.setProperty("booking_count", 15)

// Boolean property
AdropMetrics.setProperty("is_subscriber", true)

// Pass null (remove property)
AdropMetrics.setProperty("membership_level", null)
```

### Retrieving Properties

Use `AdropMetrics.properties()` to retrieve all currently set properties.

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'

const currentProperties = await AdropMetrics.properties()
console.log(currentProperties)
// { membership_level: "premium", booking_count: 15, ... }
```

<ParamField body="properties()" type="() => Promise<Record<string, any>>">
  Returns all currently set properties as a key-value object. Returns an empty object if no properties are set.
</ParamField>

### Parameters

| Parameter | Type     | Description                                    |
| --------- | -------- | ---------------------------------------------- |
| `key`     | `string` | Property key (max 64 characters)               |
| `value`   | `any`    | Property value (string, number, boolean, null) |

<Warning>
  * Property keys can be up to 64 characters.
  * String values can be up to 256 characters.
  * Number values can be up to 9007199254740991.
  * A maximum of 256 properties can be set.
</Warning>

### Built-in Properties

The Adrop SDK provides built-in properties for targeting. Use `AdropProperties` and `AdropGender` enums to set values.

#### Age (Birthday)

When you pass birthday information, age is automatically calculated.

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'
import { AdropProperties } from 'adrop-ads-react-native'

// Year only (yyyy)
AdropMetrics.setProperty(AdropProperties.BIRTH, "1990")

// Year and month (yyyyMM)
AdropMetrics.setProperty(AdropProperties.BIRTH, "199003")

// Full date (yyyyMMdd)
AdropMetrics.setProperty(AdropProperties.BIRTH, "19900315")
```

**Date Formats**

| Format     | Example    | Description    |
| ---------- | ---------- | -------------- |
| `yyyy`     | "1990"     | Year only      |
| `yyyyMM`   | "199003"   | Year and month |
| `yyyyMMdd` | "19900315" | Full date      |

#### Gender

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'
import { AdropProperties, AdropGender } from 'adrop-ads-react-native'

// Male
AdropMetrics.setProperty(AdropProperties.GENDER, AdropGender.MALE)

// Female
AdropMetrics.setProperty(AdropProperties.GENDER, AdropGender.FEMALE)

// Other
AdropMetrics.setProperty(AdropProperties.GENDER, AdropGender.OTHER)

// Unknown
AdropMetrics.setProperty(AdropProperties.GENDER, AdropGender.UNKNOWN)
```

**Gender Constants**

| Constant              | Value | Description |
| --------------------- | ----- | ----------- |
| `AdropGender.MALE`    | `"M"` | Male        |
| `AdropGender.FEMALE`  | `"F"` | Female      |
| `AdropGender.OTHER`   | `"O"` | Other       |
| `AdropGender.UNKNOWN` | `"U"` | Unknown     |

#### Setting Age Directly

You can also set age directly instead of birthday.

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'
import { AdropProperties } from 'adrop-ads-react-native'

AdropMetrics.setProperty(AdropProperties.AGE, 30)
```

<Note>
  You only need to set one of `BIRTH` or `AGE`. If both are set, `BIRTH` takes priority.
</Note>

### Custom Properties

You can set custom properties for your service. Custom properties must be defined first in the [Ad Control Console](https://console.adrop.io) under the **Targeting** menu.

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'

// Local activity app example
AdropMetrics.setProperty("region", "Seoul")
AdropMetrics.setProperty("booking_count", 5)

// Shopping mall app example
AdropMetrics.setProperty("membership_tier", "gold")
AdropMetrics.setProperty("total_purchase_amount", 1500000)

// Media app example
AdropMetrics.setProperty("favorite_genre", "drama")
AdropMetrics.setProperty("is_premium_subscriber", true)
```

<Warning>
  Custom property names must exactly match the names defined in the console. Case-sensitive.
</Warning>

### Property Usage Example

Example of setting properties when a user logs into the app.

```typescript theme={null}
import React, { useEffect } from 'react'
import { AdropMetrics } from 'adrop-ads-react-native'
import { AdropProperties, AdropGender } from 'adrop-ads-react-native'

const ProfileScreen = () => {
  useEffect(() => {
    // Get user info
    const user = getUserInfo()

    // Set built-in properties
    AdropMetrics.setProperty(AdropProperties.BIRTH, user.birthDate)
    AdropMetrics.setProperty(AdropProperties.GENDER, user.gender)

    // Set custom properties
    AdropMetrics.setProperty("membership_level", user.membershipLevel)
    AdropMetrics.setProperty("total_booking_count", user.bookingCount)
  }, [])

  return (
    // Screen component
  )
}

export default ProfileScreen
```

***

## Event Tracking

Track user behavior events to build audiences based on user actions. Use `AdropMetrics.sendEvent()` to send events.

<Note>
  `logEvent()` is deprecated. Use `sendEvent()` instead.
</Note>

### Sending Events

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'

// Simple event (no parameters)
AdropMetrics.sendEvent('app_open')

// Event with parameters
AdropMetrics.sendEvent('view_item', {
  item_id: 'SKU-123',
  item_name: 'Widget',
  item_category: 'Electronics',
  brand: 'BrandX',
  price: 29900,
})
```

### Multi-Item Events

For events that involve multiple items (e.g., purchase, begin\_checkout), pass an `items` array in the parameters.

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'

AdropMetrics.sendEvent('purchase', {
  tx_id: 'TXN-20240101-001',
  currency: 'KRW',
  items: [
    {
      item_id: 'SKU-001',
      item_name: 'Product A',
      item_category: 'Electronics',
      brand: 'BrandX',
      price: 29900,
      quantity: 1,
    },
    {
      item_id: 'SKU-002',
      item_name: 'Product B',
      price: 15000,
      quantity: 2,
    },
  ],
})
```

### Supported Event Examples

| Event Name        | Description               | Common Parameters                                                                          |
| ----------------- | ------------------------- | ------------------------------------------------------------------------------------------ |
| `app_open`        | App opened                | —                                                                                          |
| `sign_up`         | User signed up            | `method`                                                                                   |
| `push_clicks`     | Push notification clicked | `campaign_id`                                                                              |
| `page_view`       | Page viewed               | `page_id`, `page_category`, `page_url`                                                     |
| `click`           | Element clicked           | `element_id`, `element_type`, `target_url`                                                 |
| `view_item`       | Viewed item               | `item_id`, `item_name`, `item_category`, `brand`, `price`                                  |
| `view_content`    | Viewed content            | `content_id`, `content_name`, `content_type`                                               |
| `add_to_wishlist` | Added to wishlist         | `item_id`, `item_name`, `item_category`, `brand`, `price`                                  |
| `add_to_cart`     | Added to cart             | `item_id`, `item_name`, `item_category`, `brand`, `price`, `quantity`, `value`, `currency` |
| `begin_lead_form` | Began lead form           | `form_id`, `form_name`, `form_type`, `form_destination`                                    |
| `generate_lead`   | Lead generated            | `form_id`, `form_name`, `form_type`, `form_destination`, `value`, `currency`               |
| `begin_checkout`  | Began checkout            | `currency`, `items`                                                                        |
| `purchase`        | Purchase completed        | `tx_id`, `currency`, `items`                                                               |

<Note>
  * Event name must be 1–64 characters.
  * Parameter key must be 1–64 characters.
  * String parameter values are limited to 1024 characters.
</Note>

***

## Best Practices

### 1. Set Properties Before Loading Ads

```typescript theme={null}
// Correct
AdropMetrics.setProperty("membership_level", "premium")
// Load ads...

// Wrong
// Load ads...
AdropMetrics.setProperty("membership_level", "premium") // Setting after ad load means targeting won't apply
```

### 2. Update Properties When They Change

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'

const App = () => {
  useEffect(() => {
    // Set initial properties at app start
    updateUserProperties()
  }, [])

  const onUserPurchaseComplete = (purchaseAmount: number) => {
    // Update property on purchase completion
    const currentTotal = getCurrentTotalPurchase()
    AdropMetrics.setProperty("total_purchase_amount", currentTotal + purchaseAmount)
  }

  const onMembershipUpgrade = (newTier: string) => {
    // Update property on membership upgrade
    AdropMetrics.setProperty("membership_tier", newTier)
  }

  // ...
}
```

### 3. Reset Properties on Logout

```typescript theme={null}
import { AdropMetrics } from 'adrop-ads-react-native'

const onUserLogout = () => {
  // Reset properties if needed
  AdropMetrics.setProperty("membership_level", null)
  AdropMetrics.setProperty("total_booking_count", null)
}
```

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Create Audience Targeting" icon="users" href="/targeting/audience">
    Create audience targeting in the console
  </Card>

  <Card title="Sell Targeting" icon="dollar-sign" href="/targeting/sell">
    Set up targeting category sales
  </Card>

  <Card title="Banner Ads" icon="rectangle-ad" href="/sdk/react-native/banner">
    Implementing banner ads
  </Card>

  <Card title="Native Ads" icon="mobile" href="/sdk/react-native/native">
    Implementing native ads
  </Card>
</CardGroup>

***

## FAQ

<AccordionGroup>
  <Accordion title="If I don't set a UID, will targeted ads not be shown?">
    Ads will still be shown without setting a UID. UID is optional and used for sharing targeting data across platforms. Property-based and event-based targeting work without UID.
  </Accordion>

  <Accordion title="I set properties but don't see data in the console.">
    Property data is reflected in the console within 24 hours of collection. If data is not showing:

    1. Verify the property is correctly defined in the console.
    2. Check that the property key passed from the SDK exactly matches the console (case-sensitive).
    3. Verify `AdropMetrics.setProperty()` is called before loading ads.
  </Accordion>

  <Accordion title="How do I delete a property value?">
    Pass `null` as the property value to delete it:

    ```typescript theme={null}
    AdropMetrics.setProperty("membership_level", null)
    ```
  </Accordion>

  <Accordion title="Can I set array-type properties?">
    The React Native SDK does not currently support array types directly. If needed, convert to a string or split into multiple individual properties.
  </Accordion>
</AccordionGroup>
