---
title: "ウェブ体験の際にはAPIリクエストで動的なゲストデータを活用してください"
slug: "use-dynamic-guest-data-in-the-api-request-for-a-web-experience"
abstract: "APIリクエストに動的ゲストデータを含める方法を説明しています。"
---
# ウェブ体験の際にはAPIリクエストで動的なゲストデータを活用してください

ゲストデータモデルから属性やパスをコピーしてAPIリクエストで利用できます。

APIリクエストに動的なゲストデータを含めるには:

1.  コードエディターで**API**タブをクリックします。
    
2.  **データ**タブの**データセレクター**検索ボックスで、ゲストのメールアドレスやその他の識別子を入力して検索できます。これにより、データモデルの属性やパスにアクセスできます。
    
    > !ヒントコードの設定やテスト時によく使うゲストがいる場合は、**スター**アイコンをクリックしてゲストをブックマークし、検索しなくて済むようにしましょう。
    
3.  **ゲストデータモデルの「Guest data model**」で、属性またはパスの横にある「![Copy icon](https://doc.sitecore.com/api/markdown-image/personalize/ja/users/sitecore-personalize/images/copy_data.png)」をクリックし、「**Copy Path as FreeMarker**」をクリックします。
    
    ![Copying guest data to the API request](https://doc.sitecore.com/api/markdown-image/personalize/ja/users/sitecore-personalize/images/pers_guestAPI.png)
    
4.  **API**タブに貼り付けてください。
    
    > !ヒントFreeMarkerを使ってAPIリクエストにカスタムフィールドを挿入したい場合もあります。例えば、サイト訪問者の記録された状態を取得したい場合などです。そのために、loggedInStateというカスタムフィールドを作成できます。その後、FreeMarkerでAPIリクエストを設定する際に以下のパスを利用できます。 "customField": "${request.params.customField}"
    
5.  その後、該当する[HTML](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-html-in-a-web-experiment.html "Use HTML in a web experiment")、[CSS](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-css-in-a-web-experiment.html "Use CSS in a web experiment")、[またはJavaScript](https://doc.sitecore.com/personalize/ja/users/sitecore-personalize/introduction-to-experiments-in-sitecore-personalize/introduction-to-web-experiments-in-sitecore-personalize/create-a-web-experiment/use-javascript-in-a-web-experiment.html "Use JavaScript in a web experiment")エディターに再度このデータを貼り付けて参照しなければなりません。
    
6.  **「保存**」をクリックします。
    
7.  コードエディタを閉じるには ![back.png](https://doc.sitecore.com/api/markdown-image/personalize/ja/users/sitecore-personalize/images/back.png) をクリックしてください。