---
title: "ランニングのパーソナライズ"
slug: "running-personalization"
abstract: "Engage SDKを使ったSitecore CDPでのパーソナライズ運用について説明しています。"
---
# ランニングのパーソナライズ

> !注このトピックは、あなたが持っているSitecore Personalize、ウェブ体験やウェブ実験があることを前提としています。

Engage SDKを使って統合したアプリで [パーソナライズを実行](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/en/introduction-to-sitecore-personalize.html) できます。パーソナライズはウェブ体験やウェブ実験を通じて可能です。

## ウェブ体験とウェブ実験の実施

Engage SDKを初期化している間、アプリ内でウェブ体験やウェブ実験を実行するかどうかを決めることができます。クライアント側の[Engage.init()](https://doc.sitecore.com/cdp/ja/developers/api/stream-api/sitecore-engage-sdk-reference/functions/engage-init.html "Engage.init(settings)")関数のsettingsオブジェクトで[webPersonalization](https://doc.sitecore.com/cdp/ja/developers/api/integrating-with-sitecore-cdp/understanding-integration-details/settings-object.html#UUID-60c6365e-ff13-69eb-f0eb-aab96f66de3e_para-idm1903353065604344)属性をtrueに設定することで、ウェブ体験やウェブ実験を実行できます。この属性はサーバー側では利用できません。

### ウェブパーソナライゼーションスクリプトの読み込み

ウェブ体験やウェブ実験を有効にすると、アプリ内でウェブパーソナライゼーションスクリプトが読み込まれます。デフォルトでは、スクリプトは非同期で読み込みます。 [webPersonalization](https://doc.sitecore.com/cdp/ja/developers/api/integrating-with-sitecore-cdp/understanding-integration-details/settings-object.html#UUID-60c6365e-ff13-69eb-f0eb-aab96f66de3e_para-idm1903353065604344)属性をオブジェクトに設定でき、スクリプトの読み込み方法を変更できます。例えば、同期的に読み込むか、deferの有無を選べます。また、Sitecoreから受け取ったカスタムURLからスクリプトを読み込むこともできます。

> !重要 [もしあなたのStream APIターゲットエンドポイント](https://doc.sitecore.com/cdp/ja/developers/api/integrating-with-sitecore-cdp/understanding-integration-details/collect-required-details.html "Collect required details") が**JP地域**にあるなら、以下のURLからウェブパーソナライゼーションスクリプトを読み込みます:
> 
> { baseURLOverride: "https://d2ez8k04aaol9g.cloudfront.net" }

## ウェブ体験とウェブ実験の再ラン

Engage機能が最初にアプリで読み込まれ、設定オブジェクトの[webPersonalization](https://doc.sitecore.com/cdp/ja/developers/api/integrating-with-sitecore-cdp/understanding-integration-details/settings-object.html#UUID-60c6365e-ff13-69eb-f0eb-aab96f66de3e_para-idm1903353065604344)属性がtrueに設定されたとき、ウェブ体験とウェブ実験は一度だけ実行されます。体験と実験は同じページで自動的に再実行されるわけではありません。つまり、例えば以下のシナリオで体験や実験を再実行する必要があります。

-   例えば、ユーザーがフォーム欄に記入したりボタンをクリックしたりした後に、同じページでパーソナライズを複数回実行したいのです。
-   [シングルページアプリケーション(SPA)](https://developer.mozilla.org/en-US/docs/Glossary/SPA)は1つのウェブドキュメントのみで構成されており、ユーザーがルート間を移動する際にパーソナライズを実行したいのです。

Engage SDKを使えば、[Engage.triggerExperiences()](https://doc.sitecore.com/cdp/ja/developers/api/stream-api/sitecore-engage-sdk-reference/functions/engage-window-triggerexperiences.html "window.Engage.triggerExperiences()") 機能を使ってウェブ体験やウェブ実験を再実行できます。

## パーソナライズコンテンツにおける行動データおよび取引データ

Engage SDKを使えば、ウェブ体験やウェブ実験内で発生する行動データやトランザクションデータを収集・送信できます。これを実現するには、Web体験やウェブ実験内で[Engage関数](https://doc.sitecore.com/cdp/ja/developers/api/stream-api/sitecore-engage-sdk-reference/functions/functions.html "Functions") を呼び出す必要があります。

Engage SDKスクリプトを使って統合すると、例えば[ウェブ体験](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/en/create-a-variant-for-a-web-experiment-using-custom-code.html)や[ウェブ実験](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/en/create-a-variant-for-a-web-experiment-using-custom-code.html)内で[Engage.pageView()](https://doc.sitecore.com/cdp/ja/developers/api/stream-api/sitecore-engage-sdk-reference/functions/engage-pageview.html "Engage.pageView(eventData[, extensionData])")関数を呼び出すことができます。

Engage SDKパッケージを使って統合する場合、まずEngage関数をwindowオブジェクトに公開する必要があります。[Engage.init()](https://doc.sitecore.com/cdp/ja/developers/api/stream-api/sitecore-engage-sdk-reference/functions/engage-init.html "Engage.init(settings)")関数の返り値をwindowオブジェクトに割り当てることで、それらを公開できます。例えば、返り値を[window.engage](https://doc.sitecore.com/cdp/ja/developers/api/integrating-with-sitecore-cdp/understanding-integration-details/engage-init.html#UUID-4f2c13c1-58d8-5194-d3a9-d952a006fcd6_para-idm1903357411180358)に割り当てることができます。その後、[例えばウェブ体験](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/en/create-a-variant-for-a-web-experiment-using-custom-code.html)や[ウェブ実験](https://doc.sitecore.com/personalize/en/users/sitecore-personalize/en/create-a-variant-for-a-web-experiment-using-custom-code.html)内で[engage.pageView()](https://doc.sitecore.com/cdp/ja/developers/api/stream-api/sitecore-engage-sdk-reference/functions/engage-pageview.html "Engage.pageView(eventData[, extensionData])")関数を呼び出すことができます。