# セグメントでテストする

セグメントを使うと、モックユーザーに対するクレームを定義することで、設定した条件をテストできます。

たとえば、ベータユーザーにのみページやセクションを表示したい場合があります。セグメントを作成し、このモックユーザー समूहに関連付けられたプロパティを定義することで、対象とするユーザーに特有のセグメントを再現できます。

<figure><img src="/files/e36c9406bf31ef7577ac21e4c4172b97b82d4779" alt="A GitBook screenshot showing the segment editor"><figcaption><p>GitBook のセグメントエディタ。</p></figcaption></figure>

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

新しいセグメントを作成するには、条件エディタに移動し、設定アイコンをクリックします <picture><source srcset="/files/CG9bVSmdbJnQxrYiNbRI" media="(prefers-color-scheme: dark)"><img src="/files/477fc6b8be7ea4395872753916f62023abc28604" alt="The Settings icon in GitBook"></picture> 既存のセグメントの横にあるセグメントのドロップダウンで。

ここで、モックユーザーに表示されるデータを定義できます。これは表現されるデータであるため、 `visitor.claims` キーは省略されます。

#### 例

ドキュメントの例に従ってベータユーザー向けのセグメントを作成するには、新しいセグメントを作成して、次のデータを追加します。

```json
{
  "isBetaUser": true
}
```

条件エディタに戻り、作成したベータセグメントを選択すると、表示中のページが **アクセス可能であるはずだと** テストユーザーに対して示されます。

<figure><img src="/files/5434eca6066c9843047958baa294b80eb4f435c4" alt="A GitBook screenshot showing how to test a segment"><figcaption><p>GitBook でのセグメントのテスト。</p></figcaption></figure>

### 検出されたセグメント

検出されたセグメントを使うと、サイトの訪問者からどのような種類のクレームを受け取っているかを把握できます。

これらのセグメントは編集できませんが、セグメントエディタからクレームをコピーして貼り付けることで、独自のユーザーセグメントを作成できます。

### プレビューでセグメントをテストする

セグメントエディタでセグメントをテストするだけでなく、サイトの変更を表示しているプレビュー内で、セグメントをリアルタイムに使用できます。

サイトのプレビューモードでは、左上のドロップダウンを使ってセグメントを選択し、選択したセグメントでサイトがどのように表示されるかを確認してください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.com/docs/documentation/ja-gitbook-documentation/saitoakusesu/adaptive-content/testing-with-segments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
