> 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/enabling-adaptive-content.md). Agents can also search and read this documentation through its [MCP server](https://gitbook.com/docs/~gitbook/mcp).

# 適応型コンテンツの有効化

ユーザーデータを GitBook に渡す認証方法を選択します。

読者向けにドキュメント体験をカスタマイズし始めるには、適応コンテンツを有効にし、訪問者データを GitBook にどのように渡すかを決める必要があります。これにより、サイトのコンテンツは閲覧者に応じて動的に適応します。

### 適応コンテンツを有効にする

GitBook にユーザーデータを渡せるようにする前に、サイトを適応コンテンツを使用するよう設定する必要があります。

移動して [サイトの設定](https://gitbook.com/docs/documentation/ja-gitbook-documentation/manage-your-site/site-settings.md)を開き、 **Adaptive content** をサイトのオーディエンス設定で有効にします。有効にすると、「Visitor token signing key」が自動生成されます。アダプティブコンテンツの設定を続けるには、このキーが必要です。

<figure><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-96a4a97549012fd729ecfe3578922177aa40fa89%2F26_01_06_enable_adaptive_content%402x.png?alt=media" alt="A GitBook screenshot showing the enable adaptive content toggle"><figcaption><p>サイトの設定で適応コンテンツを有効にする</p></figcaption></figure>

### 訪問者スキーマを設定する

適応コンテンツを有効にした後、ユーザーがサイトを訪問した際に GitBook が受け取ると想定されるクレームの種類のスキーマを定義する必要があります。

訪問者スキーマは、これらのクレームが GitBook に送信される際にどのような構造になっているかを反映している必要があります。

たとえば、訪問者が製品のベータユーザーである可能性があると想定している場合、次のような訪問者スキーマを設定します。

```json
{
  "type": "object",
  "properties": {
    "isBetaUser": {
      "type": "boolean",
      "description": "訪問者がベータユーザーかどうか。"
    }
  },
  "additionalProperties": false
}
```

また、 [条件エディター](https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/adapting-your-content.md#working-with-the-condition-editor)でクレームを設定する際に、オートコンプリートを利用できるようになります。Visitor スキーマでサポートされている型は次のとおりです。

{% tabs %}
{% tab title="文字列" %}
文字列として渡されるクレームを読み取ります。

GitBook は動的文字列を受け付けます。つまり、ユーザーの名前、開発者トークンなどの文字列データを動的に渡すことができます。

文字列には、 **省略可能な列挙型** キーを含めることもできます。これにより、GitBook が受け取るデータを、定義済みの値のいずれかに制限できます。

```json
{
  "type": "object",
  "properties": {
    "language": {
          "type": "string",
          "description": "訪問者の言語",
          // enum プロパティ（任意）
          "enum": [
            "en",
            "fr",
            "it"
          ]
  },
  "additionalProperties": false
}
```

{% hint style="warning" %}
enum キーなしで定義された動的文字列は、 [インライン式](https://gitbook.com/docs/documentation/ja-gitbook-documentation/kontentsuwosuru/variables-and-expressions.md#use-variables-in-your-content)でのみ受け付けられます。要素（ページ、セクション、ブロック）の表示条件を指定する条件式では、enum キー付きで定義された文字列のみ使用できます。
{% endhint %}
{% endtab %}

{% tab title="ブール値" %}
ブール値として渡されるクレームを読み取ります。

```json
{
  "type": "object",
  "properties": {
    "isBetaUser": {
      "type": "boolean",
      "description": "訪問者がベータユーザーかどうか。"
    },
  },
  "additionalProperties": false
}
```

{% endtab %}

{% tab title="オブジェクト" %}
関連する値をまとめるために、オブジェクト内にクレームをネストします。

```json
{
  // トップレベルのクレーム
  "type": "object",
  "properties": {
    // ネストされたクレーム
    "access": {
      "type": "object",
      "description": "製品機能へのユーザーのアクセス",
      "properties": {
        "isAlphaUser": {
          "type": "boolean",
          "description": "訪問者が Alpha ユーザーかどうか。"
        },
        "isBetaUser": {
          "type": "boolean",
          "description": "訪問者がベータユーザーかどうか。"
        },
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
```

{% endtab %}
{% endtabs %}

### 署名なしクレームを設定する

未署名クレームは、クライアントアプリケーションによって署名されていない可能性のあるクレームを識別するための特別な種類のクレームです。URL パラメーター、未署名の Cookie、フィーチャーフラグを通じてクレームを渡す場合は、Visitor スキーマでクレームを `unsigned` として設定する必要があります。

署名なしクレームを扱う予定がある場合は、署名済みクレームと並べて “unsigned” プロパティの下に、想定しているクレームをスキーマで宣言する必要があります。

```json
{
  "type": "object",
  "properties": {
    "isBetaUser": {
      "type": "boolean",
      "description": "訪問者がベータユーザーかどうか。"
    },
    // 署名なしクレームを追加
    "unsigned": {
      "type": "object",
      "サイト訪問者の署名なしクレーム。",
      "properties": {
        "language": {
          "type": "string",
          "description": "訪問者の言語",
          // enum プロパティ（任意）
          "enum": [
            "en",
            "fr",
            "it"
          ]
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
```

### Content APIで訪問者クレームを使用する

サーバーで特定の訪問者向けに公開コンテンツを評価する必要がある場合は、Content APIを使用します。

スキーマで訪問者クレームを定義し、次のキーで訪問者JSON Web Token（JWT）に署名します。 **訪問者トークン署名キー** （オーディエンス設定内）。スキーマで宣言されたクレームのみが、アダプティブコンテンツの条件に使用されます。

信頼できるサーバーで、署名済みの訪問者JWTと対象の公開URLを交換し、有効期間の短いContent APIトークンを取得します。返された `Bearer` トークンを使って、訪問者のコンテキストでコンテンツを検索したり、ページを一覧表示したり、ページを取得したりできます。

このフローを実装する前に、コンテンツ取得時の動作を理解しておきましょう。

* 次のパラメーターを指定した単一ページのリクエストでは、 `evaluated=true` 訪問者向けに条件付きブロックとインライン式が評価されます。指定しない場合、APIは作成時のコンテンツをそのまま返します。
* 検索結果とページ一覧には、訪問者が閲覧できないコンテンツは含まれません。閲覧条件を満たさないページを直接リクエストすると、 `404`.
* 訪問者JWTの署名が無効な場合、GitBookは匿名の訪問者としてコンテンツを評価します。GitBookは指定されたクレームを信頼しません。

{% hint style="warning" %}
署名付き訪問者JWTの作成と交換は、信頼できるサーバー上でのみ行ってください。訪問者トークン署名キーやContent APIトークンを、ブラウザーのコードやログに決して公開しないでください。
{% endhint %}

### 訪問者データを GitBook に渡す

GitBook では、サイトのコンテンツを適応させるために訪問者データを渡すさまざまな方法が用意されています。スキーマを定義したら、訪問者データを GitBook にどのように渡すかを決める必要があります。

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><i class="fa-cookie">:cookie:</i></td><td><strong>Cookie</strong></td><td>公開 cookie または署名付き cookie を通じて訪問者データをドキュメントに渡します。</td><td><a href="https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/enabling-adaptive-content/cookies.md">Cookie</a></td></tr><tr><td><i class="fa-link">:link:</i></td><td><strong>URL</strong></td><td>URL のクエリパラメータを通じて訪問者データをドキュメントに渡します。</td><td><a href="https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/enabling-adaptive-content/url.md">URL</a></td></tr><tr><td><i class="fa-flag">:flag:</i></td><td><strong>機能フラグ</strong></td><td>フィーチャーフラグプロバイダーを通じて訪問者データをドキュメントに渡します。</td><td><a href="https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/enabling-adaptive-content/feature-flags.md">機能フラグ</a></td></tr><tr><td><i class="fa-lock">:lock:</i></td><td><strong>認証済みアクセス</strong></td><td>認証プロバイダーを通じて訪問者データをドキュメントに渡します。</td><td><a href="https://gitbook.com/docs/documentation/ja-gitbook-documentation/publish/adaptive-content/enabling-adaptive-content/authenticated-access.md">認証済みアクセス</a></td></tr></tbody></table>


---

# 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/enabling-adaptive-content.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.
