> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/testing-with-segments.md).

# セグメントでのテスト

モックデータを使って条件をテストします

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

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

<figure><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2FYrErMp571tYPUN2RzJJ0%2F26_01_06_segment_editor%402x.png?alt=media&amp;token=d73e0cd0-9158-41b1-bd4e-01d7def0a7aa" 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="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2FwkBqgOPry9HAcW4cxJk0%2Fsettings.svg?alt=media&amp;token=67bdbb00-ebf3-4a2d-9df8-0c822406f71c" alt="The Settings icon in GitBook"></picture> セグメントのドロップダウンにある既存のセグメントの横の

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

#### 例

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

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

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

<figure><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2FpTHHKitlueFU97EuEi14%2F26_01_06_testing_segments%402x.png?alt=media&amp;token=10f3d1d1-f604-49cd-8be6-072202bd4f37" alt="A GitBook screenshot showing how to test a segment"><figcaption><p>GitBook でセグメントをテストする。</p></figcaption></figure>

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

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

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

### プレビューでのセグメントのテスト

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

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
