# Event 및 User 정보 연동

## 1. 유저 데이터 연동

Marketap Open API에서는 사용자를 새로 등록하고, 그 속성을 업데이트 할 수 있습니다.

<table><thead><tr><th width="174.75">구성요소</th><th width="269.5">설명</th><th>예시</th></tr></thead><tbody><tr><td>유저 ID</td><td>유저를 고유하게 식별하는 값</td><td>user_id</td></tr><tr><td>유저 속성</td><td>유저의 속성에 대한 세부 정보를 나타내는 key-value 쌍</td><td>mkt_name: "홍길동",<br>mkt_phone_number: "01012345678"<br>mkt_text_message_opt_in: true</td></tr></tbody></table>

마켓탭에서는 기본적으로 지원하는 속성 외에도 필요한 유저 속성의 커스터마이징이 가능합니다. 관련 내용은 아래 페이지를 통해 확인해주세요.

{% content-ref url="../sdk/user-profile/property" %}
[property](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/taxonomy/sdk/user-profile/property)
{% endcontent-ref %}

유저를 삭제에 관련된 내용은 아래 페이지를 통해 확인해주세요.

{% content-ref url="user-deletion" %}
[user-deletion](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/taxonomy/server/user-deletion)
{% endcontent-ref %}

해당 API를 통해, 플랫폼이 기존에 수집하였던 유저 데이터를 쉽게 마이그레이션 할 수 있습니다. 관련 내용은 아래 페이지를 통해 확인해주세요.

{% content-ref url="user-event/migration" %}
[migration](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/taxonomy/server/user-event/migration)
{% endcontent-ref %}

{% hint style="danger" %}
유저 데이터를 연동할 때에는 반드시 유저의 **광고성 메세지 수신동의 여부**를 연동해주세요. 마켓탭은 아예 수집되지 않은 고객에 대해서 수신동의 여부를 **따로 체크하지 않습니다**. 명시적으로 "동의하지 않음"을 표시한 유저에 대해서만 광고 메세지 발송을 제한하고 있습니다. 자세한 내용은 [여기에서](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/sdk/user-profile/property#undefined) 확인해주세요.
{% endhint %}

### 요청 예시

{% hint style="success" %}
[여기 문서](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/open-api/user-event-request#post-v1-api-profile-user)에서 정확한 API 스펙을 확인하고, 요청을 테스트로 보내볼 수 있습니다.
{% endhint %}

**매개변수**:

* user\_id: 유저의 id
* properties?: 업데이트할 유저의 속성

```json
{
  "profiles": [
    {
      "user_id": "test-user-123",
      "properties": {
        "mkt_birth": "1999-05-07",
        "mkt_name": "GilDong Hong"
      }
    }
  ]
}
```

## 2. 이벤트 데이터 연동

Marketap Open API는 사용자의 행동 데이터를 이벤트로 기록하여 Marketap 콘솔에서 관리하고 분석할 수 있도록 지원합니다.**이벤트 이름**, **이벤트 속성**, 그리고 **아이템 속성**을 사용하여 다양한 데이터를 수집할 수 있습니다.

<table><thead><tr><th width="178">구성요소</th><th width="297">설명</th><th>예시</th></tr></thead><tbody><tr><td>이벤트 이름</td><td>사용자 행동을 정의하는 고유 값.</td><td>mkt_purchase, open_discount_event_zone, subscription_start</td></tr><tr><td>이벤트 속성</td><td>이벤트에 대한 추가 정보를 제공하는 key-value 쌍.</td><td><p>source: homepage, </p><p>amount: 49.99</p></td></tr><tr><td>아이템 속성</td><td>이벤트와 관련된 상품/서비스의 세부 정보를 제공하는 배열 형태의 속성.</td><td><p>mkt_items: [{ </p><p>    name: "T-shirt", </p><p>    price: 25.00, </p><p>    quantity: 2 </p><p>}]</p></td></tr></tbody></table>

마켓탭에서는 이벤트, 이벤트 속성, 아이템 속성 모두 커스터마이징이 가능합니다. 관련 내용은 아래 카드를 통해 확인해주세요.

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>이벤트 확인하기</td><td><a href="../sdk/event/predefined">predefined</a></td></tr><tr><td>이벤트 속성 확인하기</td><td><a href="../sdk/event/property">property</a></td></tr><tr><td>마켓탭에서 자동으로 수집되는 이벤트 및 속성 확인하기</td><td><a href="../sdk/event/auto-collect">auto-collect</a></td></tr></tbody></table>

### 요청 예시

{% hint style="success" %}
[여기 문서](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/open-api/user-event-request#post-v1-api-events)에서 정확한 API 스펙을 확인하고, 요청을 테스트로 보내볼 수 있습니다.
{% endhint %}

**매개변수**:

* user\_id?: 이벤트를 일으킨 유저의 id, null일 경우 비회원 이벤트 입니다.
* name: 이벤트 이름 (예: open\_discount\_event\_zone).
* properties?: 이벤트와 함께 기록할 속성.
  * mkt\_items?: 이벤트와 관련된 아이템 속성, 리스트로 전달해야 합니다.
* timestamp?: 이벤트가 일어난 시간

{% hint style="warning" %}
시간을 직접 입력하는 경우,현재 기준 최대 한시간 차이를 권장합니다. 수집 시간과 실제 이벤트시간의 차이가 큰 경우 개발팀에게 문의해주세요.
{% endhint %}

```json
{
  "events": [
    {
      "user_id": "test-user-123",
      "event_name": "open_discount_event_zone",
      "properties": {
        "mkt_page_url": "http://localhost:3000/checkout",
        "mkt_search_query": "검색",
        "mkt_items": [
          {
            "mkt_product_id": "PRODUCT_1",
            "mkt_product_name": "멋진 운동화",
            "mkt_category1": "운동화",
            "mkt_category2": "신발"
          }
        ]
      },
      "timestamp": "2025-02-02T05:30:11.052Z"
    }
  ]
}
```

### 3. 기기 데이터 연동&#x20;

아래 API를 통해 기기 토큰을 등록하거나 업데이트할 수 있으며, 사용자 정보와의 매칭 정보를 함께 관리할 수 있습니다. 이를 통해 SDK 연동 이전에도 기존 고객 기기 토큰을 활용한 푸시 메시지 발송이 가능합니다.

{% content-ref url="../../open-api/user-event-request" %}
[user-event-request](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/open-api/user-event-request)
{% endcontent-ref %}

해당 API를 통해, 플랫폼이 기존에 수집하였던 유저 데이터를 쉽게 마이그레이션 할 수 있습니다. 관련 내용은 아래 페이지를 통해 확인해주세요.

{% content-ref url="user-event/undefined" %}
[undefined](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/taxonomy/server/user-event/undefined)
{% endcontent-ref %}

### 요청 예시

{% hint style="success" %}
[여기 문서](https://docs.marketap.io/t3ZS4WXNMj0HK27EtIMV/developer/open-api/user-event-request#post-v1-api-profile-user)에서 정확한 API 스펙을 확인하고, 요청을 테스트로 보내볼 수 있습니다.
{% endhint %}

**매개변수:**

* user\_id?: 유저의 id
* tokens: 업데이트할 디바이스의 토큰
* platform: 디바이스의 플랫폼 (IOS / ANDROID / WEB)

```
{
  "profiles": [
    {
      "user_id": "test-user-123",
      "device": {
        "tokens": "fSVrgIChQiuGOMQ4KEkY2C:APA91bH7CB9JcSxQ4RElRyceXtq7d6qQL2Dr_OvPSkBClCeZSQ8CaYhqyHFyu_wUPKqoVtZWLUXoyrByYeW84I_EKaGPtxZD",
        "platform": "ANDROID"
      },
      "timestamp": "2025-02-06T05:30:11.052Z"
    }
  ]
}
```
