> ## 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.

# 타겟팅 설정

> REST API에서 사용자 속성 및 문맥 타겟팅을 설정하는 방법을 안내합니다.

타겟팅을 사용하면 특정 사용자 그룹이나 문맥에 맞는 광고를 노출할 수 있습니다. REST API에서는 오디언스 타겟팅과 문맥 타겟팅을 모두 지원합니다.

## 오디언스 타겟팅

사용자 속성을 기반으로 광고를 타겟팅합니다.

### 요청 파라미터

<ParamField header="Authorization" type="string" required>
  App Key (adrop\_service.json에서 확인)
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

<ParamField body="uid" type="string" required>
  사용자 고유 식별자
</ParamField>

<ParamField body="value" type="string" required>
  속성 데이터 (JSON 문자열). 프리셋 및 커스텀 속성 포함
</ParamField>

<ParamField body="platform" type="string">
  플랫폼. 예: `web`, `android`, `ios`
</ParamField>

<ParamField body="adid" type="string">
  광고 식별자 (ADID/IDFA)
</ParamField>

### 응답

<ResponseField name="code" type="integer">
  응답 코드. `0`은 성공
</ResponseField>

<ResponseField name="msg" type="string">
  응답 메시지
</ResponseField>

<ResponseExample>
  ```json 성공 응답 theme={null}
  {
      "code": 0,
      "msg": "OK"
  }
  ```
</ResponseExample>

***

## 프리셋 속성

Adrop에서 미리 정의한 표준 속성입니다. 모든 SDK와 REST API에서 동일한 형식을 사용합니다.

### 생년월일 (BIRTH)

| 키       | 값 예시       | 형식               |
| ------- | ---------- | ---------------- |
| `BIRTH` | `2024`     | yyyy (연도만)       |
| `BIRTH` | `202401`   | yyyyMM (연월)      |
| `BIRTH` | `20240101` | yyyyMMdd (전체 날짜) |

### 성별 (GDR)

| 키     | 값   | 의미               |
| ----- | --- | ---------------- |
| `GDR` | `M` | 남성 (Male)        |
| `GDR` | `F` | 여성 (Female)      |
| `GDR` | `U` | 알 수 없음 (Unknown) |

### 알 수 없음 값

| 키   | 값   | 설명                         |
| --- | --- | -------------------------- |
| `*` | `U` | 모든 속성에서 "알 수 없음"을 나타낼 때 사용 |

<Note>
  프리셋 속성 키는 대문자를 사용합니다: `BIRTH`, `GDR`
</Note>

***

## 커스텀 속성

콘솔에서 정의한 커스텀 속성을 사용할 수 있습니다.

### 커스텀 속성 설정

1. [Adrop 콘솔](https://console.adrop.io)에서 **타겟팅** 메뉴로 이동
2. **오디언스 타겟팅** 탭에서 커스텀 속성 생성
3. API에서 해당 키-값으로 속성 전송

```javascript theme={null}
const properties = {
    // 프리셋 속성
    BIRTH: '19931225',
    GDR: 'M',

    // 커스텀 속성 (콘솔에서 정의)
    membership: 'premium',
    lastPurchaseDate: '2024-01-15',
    favoriteCategory: 'electronics'
};
```

<Warning>
  커스텀 속성의 모든 값은 문자열(STRING) 타입입니다.
</Warning>

***

## 문맥 타겟팅

페이지나 콘텐츠의 문맥에 따라 광고를 타겟팅합니다. 광고 요청 시 `contextId` 파라미터를 추가합니다.

### 문맥 타겟팅 설정

1. [Adrop 콘솔](https://console.adrop.io)에서 **타겟팅** 메뉴로 이동
2. **문맥 타겟팅** 탭에서 문맥 생성
3. 광고 요청 시 `contextId` 파라미터 사용

### 광고 요청 시 문맥 적용

```
GET https://api-v2.adrop.io/request?unit=YOUR_UNIT_ID&contextId=sport
```

<CodeGroup>
  ```javascript Node.js theme={null}
  const axios = require('axios');

  const config = {
      method: 'get',
      baseURL: 'https://api-v2.adrop.io',
      url: '/request',
      params: {
          unit: 'YOUR_UNIT_ID',
          uid: 'USER_ID',
          pf: 'web',
          contextId: 'sport'  // 콘솔에서 생성한 Context ID
      },
      headers: {
          'Authorization': 'YOUR_APP_KEY'
      }
  };

  axios.request(config)
      .then((response) => {
          console.log(JSON.stringify(response.data));
      })
      .catch((error) => {
          console.log(error);
      });
  ```

  ```python Python theme={null}
  import requests

  url = "https://api-v2.adrop.io/request"
  params = {
      "unit": "YOUR_UNIT_ID",
      "uid": "USER_ID",
      "pf": "web",
      "contextId": "sport"
  }
  headers = {
      "Authorization": "YOUR_APP_KEY"
  }

  response = requests.get(url, params=params, headers=headers)
  print(response.json())
  ```

  ```curl cURL theme={null}
  curl -X GET "https://api-v2.adrop.io/request?unit=YOUR_UNIT_ID&uid=USER_ID&pf=web&contextId=sport" \
    -H "Authorization: YOUR_APP_KEY"
  ```
</CodeGroup>

***

## 모범 사례

<CardGroup cols={2}>
  <Card title="사용자 ID 일관성" icon="fingerprint">
    동일한 사용자에게는 항상 같은 `uid`를 사용하세요. 일관된 ID는 정확한 타겟팅의 핵심입니다.
  </Card>

  <Card title="속성 업데이트" icon="rotate">
    사용자 정보가 변경되면 즉시 `/property` 엔드포인트를 호출하여 업데이트하세요.
  </Card>

  <Card title="프리셋 형식 준수" icon="check">
    `BIRTH`와 `GDR` 속성은 정해진 형식을 정확히 사용해야 합니다.
  </Card>

  <Card title="문맥 활용" icon="tags">
    뉴스, 스포츠, 쇼핑 등 페이지 성격에 맞는 문맥 타겟팅을 활용하세요.
  </Card>
</CardGroup>

***

## 관련 문서

<CardGroup cols={2}>
  <Card title="오디언스 타겟팅" icon="users" href="/ko/targeting/audience">
    콘솔에서 오디언스 타겟팅 설정
  </Card>

  <Card title="문맥 타겟팅" icon="tags" href="/ko/targeting/context">
    콘솔에서 문맥 타겟팅 설정
  </Card>
</CardGroup>
