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

# 任意のサードパーティソリューションで Kameleoon にユーザーデータを受信する

> Data API の Map エンドポイントを使用して任意のサードパーティツールから Kameleoon にユーザーデータを送信し、キャンペーンのターゲティング条件として使用します。

## Kameleoon にユーザーデータを送信する

[Map エンドポイント](../../../developer-docs/apis/data-api-rest/overview#map-エンドポイント) を使用すると、指定されたキー (通常は訪問者コードまたは内部ユーザー ID) に対して追加データを保存できます。このデータは、[Activation API](../../../developer-docs/apis/activation-api-js/api-reference/api-reference#retrievedatafromremotesource) および当社のすべての [SDK](../../../developer-docs/sdks/web-sdks/nodejs-sdk#getremotedata) で利用可能な `retrieveDataFromRemoteSource` メソッドを使用して、ターゲティングおよびセグメンテーションの目的で取得および使用できます。指定されたキーに対して保存されているデータを取得するために Map エンドポイントを使用することもできます。

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/receive-user-data-in-kameleoon-with-any-third-party-solution/Capture-decran-2025-02-27-a-10.40.06.png)
</Frame>

**ペイロードの例:**

```json theme={null}
{
     "U67891": {
         "userSegment": ["Tech Enthusiast", "Gamer"],
         "categoryAffinities": [
             {
                 "id": "0567012",
                 "name": "Gaming Keyboards"
             },
             {
                 "id": "0456789",
                 "name": "Mechanical Keyboards"
             }
         ]
     },
     "U23456": {
         "userSegment": ["Fitness & Outdoors", "Health Conscious"],
         "categoryAffinities": [
             {
                 "id": "0321009",
                 "name": "Smartwatches"
             },
             {
                 "id": "0789456",
                 "name": "Wireless Earbuds"
             }
         ]
     },
     "U98765": {
         "userSegment": ["Music Lover", "Audiophile"],
         "categoryAffinities": [
             {
                 "id": "0984321",
                 "name": "Bluetooth Speakers"
             },
             {
                 "id": "0678901",
                 "name": "Noise-Canceling Headphones"
             }
         ]
     }
 }
```

**リクエストの例:**

```bash theme={null}
curl -L 'https://na-data/map/maps' \\
 -H 'Content-Type: application/json' \\
 -d '{"U67891":{"userSegment":["Tech Enthusiast","Gamer"],"categoryAffinities":[{"id":"0567012","name":"Gaming Keyboards"},{"id":"0456789","name":"Mechanical Keyboards"}]},"U23456":{"userSegment":["Fitness & Outdoors","Health Conscious"],"categoryAffinities":[{"id":"0321009","name":"Smartwatches"},{"id":"0789456","name":"Wireless Earbuds"}]},"U98765":{"userSegment":["Music Lover","Audiophile"],"categoryAffinities":[{"id":"0984321","name":"Bluetooth Speakers"},{"id":"0678901","name":"Noise-Canceling Headphones"}]}}'
```

## Kameleoon でユーザーデータを取得する

### カスタムデータを作成する

Kameleoon のカスタムデータを作成して設定する必要があります。

Kameleoon のカスタムデータを作成して設定する必要があります。手順は以下のとおりです:

1. **Settings** > **Custom data** をクリックします。
2. カスタムデータに名前を付けます。
3. プロジェクトを選択します。
4. 取得方法として **Custom JavaScript code** を選択します。

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/receive-user-data-in-kameleoon-with-any-third-party-solution/Capture-decran-2025-02-27-a-10.24.41.png)
</Frame>

以下のコードを使用してください。

`NAME_OF_YOUR_CUSTOMDATA` をカスタムデータの名前に、`NAME_OF_YOUR_USER_ID` をユーザー ID に置き換えてください。

```javascript theme={null}
Kameleoon.API.Data.retrieveDataFromRemoteSource(NAME_OF_YOUR_USER_ID, function(data) {
      for (const [key, value] of Object.entries(data)) {
          Kameleoon.API.Data.setCustomData('NAME_OF_YOUR_CUSTOMDATA',key)
      }
  });
  return { "value": null}
```

4. タイプ **List** とフォーマット **String** を選択します。
5. スコープ **Page** を選択します。

#### カスタムデータポイントに関連付けられたターゲティング条件の値を保存する

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/receive-user-data-in-kameleoon-with-any-third-party-solution/Capture-decran-2025-02-27-a-10.28.46.png)
</Frame>

詳細はこちら: [カスタムデータの作成とプッシュ](../../assets/custom-data/create-custom-data)

### セグメントを作成する

#### プロジェクト用に新しいセグメントを作成する

セグメントをセットアップするには、以下の手順に従ってください:

1. **Settings** > **Custom data** をクリックします。
2. セグメントに名前を付けます。
3. プロジェクトを選択します。
4. セグメントの **campaign type** を選択します。

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/receive-user-data-in-kameleoon-with-any-third-party-solution/Capture-decran-2025-02-27-a-10.31.56.png)
</Frame>

### 先ほど作成したカスタムデータを使用してセグメントを作成する

カスタムデータを設定したら、Kameleoon セグメントビルダーでセグメントを構築できます。カスタムデータを選択し、**is among the values** を選択すると、サードパーティツールからのすべての `user data` のリストが表示されます。`user data` を選択してパーソナライゼーションと実験でのターゲティングを有効化します。

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/receive-user-data-in-kameleoon-with-any-third-party-solution/Capture-decran-2025-02-27-a-10.36.26-1920x901.png)
</Frame>

### このセグメントを実験で使用する

[詳細はこちら](../../assets/segments/create-a-segment)
