MAUI SDK+ 統合ガイド
このページでは、Rokt Ecommerce MAUI SDK+の実装方法について説明します。SDK+は、設定された画面でユーザーとトランザクションデータをRoktに渡し、Roktが確認画面でのオファーなどの関連するエクスペリエンスを表示できるようにします。
1. Add the Rokt SDK+ to Your MAUI App#
プロジェクトにSDK+パッケージを追加します:
dotnet add package mParticle.MAUI
dotnet add package mParticle.MAUI.Kits.Rokt
dotnet add package mParticle.MAUI.Kits.Rokt.Payments
mParticle.MAUI.Kits.Rokt.Paymentsには、コアRoktキットがトランジティブに含まれています。
Androidの場合、アクティビティがMauiAppCompatActivityを拡張していることを確認する必要があります。
2. Initialize the Rokt SDK+#
アプリケーションのスタートアップに次の初期化スニペットを挿入します。SDK+は他のSDK+ API呼び出しの前に初期化される必要があります。your-keyとyour-secretをRoktチームから提供されたキーとシークレットに置き換えてください。
using mParticle.MAUI;
string key = "";
string secret = "";
#if __ANDROID__
key = "your-key";
secret = "your-secret";
#elif __IOS__
key = "your-key";
secret = "your-secret";
#endif
// Initialize the SDK+
var options = new MParticleOptions()
{
ApiKey = key,
ApiSecret = secret
};
// Specify the data environment with Environment:
// Set it to Development if you are still testing your integration.
// Set it to Production if your integration is ready for production data.
// The default is AutoDetect which attempts to detect the environment automatically.
options.Environment = mParticle.MAUI.Environment.Development;
// Enter your custom subdomain if you are using a first-party domain configuration (optional)
options.NetworkOptions = new NetworkOptions()
{
CustomBaseUrl = "https://rkt.example.com"
};
// Identify the current user:
var identifyRequest = new IdentityApiRequest();
identifyRequest.UserIdentities = new Dictionary<UserIdentity, string>()
{
#if __ANDROID__
// Preferred: pass the customer's raw, unhashed email.
// If you can only provide a SHA-256-hashed email, use UserIdentity.Other instead — do not pass both.
{ UserIdentity.Email, "j.smith@example.com" },
{ UserIdentity.Other, "SHA-256 hashed email" }, // only if raw email unavailable
// If you can only provide a SHA-256-hashed mobile number, use Other2 instead of MobileNumber — do not pass both.
{ UserIdentity.Other2, "SHA-256 hashed mobile number" }, // only if raw mobile unavailable
{ UserIdentity.MobileNumber, "+13125551515" },
{ UserIdentity.CustomerId, "cust_10482" }
#elif __IOS__
// Preferred: pass the customer's raw, unhashed email.
// If you can only provide a SHA-256-hashed email, use UserIdentity.Other instead — do not pass both.
{ UserIdentity.Email, "j.smith@example.com" },
{ UserIdentity.Other, "SHA-256 hashed email" }, // only if raw email unavailable
// Customer phone number in E.164 format.
{ UserIdentity.MobileNumber, "+13125551515" },
// If you can only provide a SHA-256-hashed mobile number, use Other2 instead of MobileNumber — do not pass both.
{ UserIdentity.Other2, "SHA-256 hashed mobile number" }, // only if raw mobile unavailable
{ UserIdentity.CustomerId, "cust_10482" }
#endif
};
// If the user is identified with their email address, set additional user attributes.
options.IdentifyRequest = identifyRequest;
OnUserIdentified onIdentifyComplete = newUser =>
{
if (newUser != null)
{
newUser.SetUserAttribute("example attribute key", "example attribute value");
}
};
options.IdentityStateListener = onIdentifyComplete;
// Register the Rokt kit with mParticle before initialization
RoktKit.Register();
MParticle.Instance.Initialize(options);
アプリケーションのスタートアップに初期化スニペットを挿入すると、次のカスタマイズ可能なフィールドが表示されます:
1Entering your Rokt key and secret#
プラットフォーム固有のブロック内にyour-keyとyour-secretを設定し、Roktアカウントマネージャーから提供されたキーとシークレットの値に置き換えます。
2Setting your data environment#
options.EnvironmentをmParticle.MAUI.Environment.Developmentに設定してテスト中にデータを開発環境にルーティングし、mParticle.MAUI.Environment.Productionに設定して本番環境にライブ顧客活動を送信します。
3Entering a custom first-party domain#
First-Party Domain Configurationの指示に従い、options.NetworkOptions.CustomBaseUrlをカスタムサブドメインに設定してから、MParticle.Instance.Initialize(options)を呼び出します。トラフィックをRoktのデフォルトエンドポイントに送信するには、options.NetworkOptionsを省略します。
4Identifying your user and setting attributes#
identifyRequest.UserIdentitiesにおいて、ユーザーの生のハッシュされていないメールをUserIdentity.Emailを通じて渡します。ハッシュされたメールやその他の識別子については、Supported user identifiersを参照してください。識別された後、追加のユーザー属性を設定するためにIdentityStateListenerコールバックを使用します — 推奨されるリストについてはUser attributesを参照してください。
OnUserIdentified onIdentifyComplete = newUser =>
{
if (newUser != null)
{
newUser.SetUserAttribute("example attribute key", "example attribute value");
}
};
options.IdentityStateListener = onIdentifyComplete;
初期化スニペットには常にidentifyRequestを含めてください。初期化時にユーザーのメールがない場合は、UserIdentity.Emailエントリを省略してください — SDK+はそれでも初期化され、後でIdentify the userを通じてユーザーを識別できます。識別の失敗を処理する方法についてはError handlingを参照してください — エラーハンドリングがない場合、大規模なデータの整合性の問題が発生する可能性があります。
3. Identify the User#
SDK+ initialization scriptは、スクリプトのidentifyRequestオブジェクトで提供された識別子を使用して現在のユーザーを識別します。SDKの初期化後、ユーザーがログイン、ログアウト、または他の識別子を提供するたびに(例:チェックアウト時)、以下に説明する適切な方法を使用してユーザーの識別を同期し続ける必要があります。
サポートされているユーザー識別子サポートされているユーザー識別子 への直接リンク
サポートされているユーザー識別子を表示
| フィールド | タイプ | 説明 |
|---|---|---|
email | string | 顧客の生の、ハッシュ化されていないメールアドレスを渡します。 |
mobile | string | 顧客の電話番号をE.164形式で渡します。 |
customerid | string | 内部の顧客/アカウント識別子を渡します。ログインしているユーザーにはすべての画面で送信してください。 |
other | string | SHA-256でハッシュ化されたメールを渡します。生のメールを提供できない場合にのみ使用してください — emailとotherの両方を渡さないでください。(Androidパスのみ。) |
other2 | string | SHA-256でハッシュ化された電話番号を渡します。生の電話番号を提供できない場合にのみ使用してください — mobileとother2の両方を渡さないでください。(Androidパスのみ。) |
emailSha256 | string | SHA-256でハッシュ化されたメールを渡します。生のメールを提供できない場合にのみ使用してください — emailとemailSha256の両方を渡さないでください。(iOSパスのみ。) |
mobileSha256 | string | SHA-256でハッシュ化された電話番号を渡します。生の電話番号を提供できない場合にのみ使用してください — mobileとmobileSha256の両方を渡さないでください。(iOSパスのみ。) |
ユーザーを識別するには:
1Create an identifyRequest object#
ユーザーの識別子を含むidentifyRequestオブジェクトを作成します。ユーザーの生の、ハッシュ化されていないメールアドレスをUserIdentity.Emailフィールドに統合する必要があります。
2Set additional user attributes via AddSuccessListener#
追加のユーザー属性を設定するには、識別結果のAddSuccessListenerコールバックを使用します。identifyRequestが成功した場合、リスナー内で設定したユーザー属性は識別されたユーザーに割り当てられます。
3Send the request using the method that matches the user's action#
ユーザーのアクションに一致するメソッドにidentifyRequestを渡します:
MParticle.Instance.Identity.Login: ユーザーがログインまたはアカウントを作成したときに呼び出します。MParticle.Instance.Identity.Identify: ログイン遷移なしでセッション中にユーザーのメールを取得したときに呼び出します(例:ゲストがチェックアウト時にメールを入力する)。MParticle.Instance.Identity.Logout: ユーザーがログアウトしたときに呼び出します。
これらのメソッドを呼び出すと、SDKの現在のユーザーの状態の記録が遷移します。loginとlogoutメソッドは、Roktのアトリビューションを改善するために対応するイベントを自動的にログします。
例えば、Jane Smithという名前のユーザーで、メールがj.smith@example.com、電話番号が+13125551515、顧客IDがcust_10482の場合:
// 1. Create the identifyRequest object
var identifyRequest = new IdentityApiRequest();
identifyRequest.UserIdentities = new Dictionary<UserIdentity, string>()
{
#if __ANDROID__
// Preferred: pass the customer's raw, unhashed email.
// If you can only provide a SHA-256-hashed email, use UserIdentity.Other instead — do not pass both.
{ UserIdentity.Email, "j.smith@example.com" },
{ UserIdentity.Other, "SHA-256 hashed email" }, // only if raw email unavailable
// If you can only provide a SHA-256-hashed mobile number, use Other2 instead of MobileNumber — do not pass both.
{ UserIdentity.Other2, "SHA-256 hashed mobile number" }, // only if raw mobile unavailable
{ UserIdentity.MobileNumber, "+13125551515" },
{ UserIdentity.CustomerId, "cust_10482" }
#elif __IOS__
// Preferred: pass the customer's raw, unhashed email.
// If you can only provide a SHA-256-hashed email, use UserIdentity.Other instead — do not pass both.
{ UserIdentity.Email, "j.smith@example.com" },
{ UserIdentity.Other, "SHA-256 hashed email" }, // only if raw email unavailable
// Customer phone number in E.164 format.
{ UserIdentity.MobileNumber, "+13125551515" },
// If you can only provide a SHA-256-hashed mobile number, use Other2 instead of MobileNumber — do not pass both.
{ UserIdentity.Other2, "SHA-256 hashed mobile number" }, // only if raw mobile unavailable
{ UserIdentity.CustomerId, "cust_10482" }
#endif
};
// 2. User attributes are set using the AddSuccessListener callback
// 3. Call one of the following methods that best matches the user's action:
MParticle.Instance.Identity.Login(identifyRequest)
.AddSuccessListener(result =>
{
result.User.SetUserAttribute("firstname", "Jane");
result.User.SetUserAttribute("lastname", "Smith");
}); // Call when the user logs in or creates an account
MParticle.Instance.Identity.Identify(identifyRequest)
.AddSuccessListener(result =>
{
result.User.SetUserAttribute("firstname", "Jane");
result.User.SetUserAttribute("lastname", "Smith");
}); // Call when you obtain the user's email mid-session, but not during a login
MParticle.Instance.Identity.Logout(); // Call when the user logs out
4. Set User Attributes#
ユーザーがアプリをナビゲートする際に、段階的にユーザー属性を設定します。チェックアウト時だけでなく、設定する属性が多いほど、Roktは顧客をよりよく解決し、関連するオファーを提供できます。
using mParticle.MAUI;
// Retrieve the current user. This will only succeed if you have identified the user during SDK+ initialization or by calling the identify method.
var currentUser = MParticle.Instance.Identity.CurrentUser;
// Once you have successfully set the current user, you can set user attributes with:
currentUser.SetUserAttribute("custom-attribute-name", "custom-attribute-value");
// Note: all user attributes (including list attributes and tags) must have distinct names.
// Rokt recommends setting as many of the following user attributes as possible:
currentUser.SetUserAttribute("firstname", "John");
currentUser.SetUserAttribute("lastname", "Doe");
// Phone numbers can be formatted either as '1234567890', or '+1 (234) 567-8901'
currentUser.SetUserAttribute("mobile", "3125551515");
currentUser.SetUserAttribute("age", "33");
currentUser.SetUserAttribute("gender", "M");
currentUser.SetUserAttribute("billingcity", "Brooklyn");
currentUser.SetUserAttribute("billingstate", "NY");
currentUser.SetUserAttribute("billingzipcode", "123456");
currentUser.SetUserAttribute("dob", "yyyymmdd");
currentUser.SetUserAttribute("title", "Mr");
currentUser.SetUserAttribute("language", "en");
currentUser.SetUserAttribute("predictedltv", "136.23");
// You can create a user attribute to contain a list of values
currentUser.SetUserAttribute("favorite-genres", string.Join(", ", new string[] { "documentary", "comedy", "romance", "drama" }));
// To remove a user attribute, call RemoveUserAttribute and pass in the attribute name.
currentUser.RemoveUserAttribute("attribute-to-remove");
ユーザー属性ユーザー属性 への直接リンク
収集可能な限り、以下を設定してください:
すべてのユーザー属性を表示
| フィールド | タイプ | 説明 |
|---|---|---|
firstname | string | 顧客の名。パーソナライズに使用されます。 |
lastname | string | 顧客の姓。パーソナライズに使用されます。 |
mobile | string | 電話番号は 1112345678 または +1 (222) 345-6789 の形式で。アイデンティティ解決と関連性に使用されます。 |
age | integer | 顧客の年齢。dob の代替。適格性と関連性に使用されます。 |
dob | string | 生年月日、yyyymmdd。age の代替。適格性と関連性に使用されます。 |
gender | string | 顧客の性別。例: M、F、Male、Female。関連性に使用されます。 |
title | string | 敬称。例: Mr、Mrs、Ms。パーソナライズに使用されます。 |
language | string | 購入に関連付けられたISO 639-1言語コード。関連性に使用されます。 |
billingcity | string | 請求先の市。関連性に使用されます。 |
billingstate | string | 請求先の州/省/地域。関連性と適格性に使用されます。 |
billingzipcode | string | 完全なZIPまたは郵便番号(米国の優先はZIP+4)。アイデンティティ解決と関連性に使用されます。 |
billingaddress1 | string | 請求先の住所1行目。アイデンティティ解決と関連性に使用されます。 |
billingaddress2 | string | 請求先の住所2行目。アイデンティティ解決に使用されます。 |
country | string | ISO 3166-1 alpha-2国コード(例: US、GB、AU)。適格性と関連性に使用されます。 |
birthyear | integer | 顧客の出生年(例: 1990)。適格性と関連性に使用されます。 |
newcustomer | boolean | 初めての購入者かどうか。関連性に使用されます。 |
customertype | string | ユーザーが認証されているかどうか(guest / logged_in)。関連性に使用されます。 |
loyaltytier | string | パートナーのロイヤルティプログラムの階層。関連性と適格性に使用されます。 |
loyaltyid | string | ロイヤルティプログラムのメンバーID。アイデンティティ解決に使用されます。 |
predictedltv | decimal | 通常、パートナーの機械学習モデルからの予測される生涯価値。関連性のために使用されます。 |
subscriptionstatus | string | 該当する場合のサブスクリプション状態 (active、trial、churned、paused、none)。関連性と適格性のために使用されます。 |
customersegment | string | パートナー内部のセグメンテーション(例:vip、at_risk、new、reactivated)。関連性のために使用されます。 |
acquisitionchannel | string | 顧客が獲得されたチャネル。関連性のために使用されます。 |
すべてのユーザー属性(リスト属性を含む)は、異なる名前を持たなければなりません。
5. Track Funnel Events#
画面ビュー、コマースイベント、およびカスタムイベントを追跡して、Roktが各顧客がどの段階にいるかを理解できるようにします。
画面の名前(例:"homepage"、"product_detail_page")を使用してMParticle.Instance.LogScreenを呼び出します。情報辞書に追加のカスタム属性を含めます。
MParticle.Instance.LogScreen(
"homepage",
new Dictionary<string, string>() { { "custom-attribute", "custom-value" } }
);
コマースイベントは、ユーザーの旅における製品レベルの詳細を含みます。顧客が行う各製品アクションに対して別々のコマースイベントをトリガーします。
完全なコマースイベントのカバレッジに投資することは、統合中にできる最も効果的なことの1つです。各イベントは、顧客がどの段階にいるかについてRoktに異なる情報を提供します:製品ビューは探索を示し、カートへの追加は検討を示し、チェックアウトの開始は購入意図を示し、完了した購入はコンバージョンを確認します。豊富なシグナルにより、Roktはオファーをより効果的にパーソナライズし、配置のパフォーマンスを正確に測定し、コンバージョンを適切なタッチポイントに帰属させることができます。この作業を最初の統合中に行うことで、後のレトロフィットを避けることもできます。シグナルは時間とともに複合されます:Roktが受け取る各イベントは、パーソナライズを鋭くし、帰属の精度を向上させ、将来の訪問で顧客ベースをよりよく解決しセグメント化するために使用されるコンテキストを追加します。
コマースイベントは、顧客アクションを識別する製品アクション定数を使用してCommerceEventでログに記録されます(製品の閲覧、カートへの追加、チェックアウトの開始、購入の完了など)。以下のセクションでは、サポートされているアクションタイプをリストし、イベントの組み立てを説明します。
すべての製品アクションタイプを表示
| 顧客アクション | 製品アクション定数 |
|---|---|
| 製品詳細ページが表示された | ProductAction.ViewDetail |
| 製品がクリックされた | ProductAction.Click |
| アイテムがカートに追加された | ProductAction.AddToCart |
| アイテムがカートから削除された | ProductAction.RemoveFromCart |
| アイテムがウィッシュリストに追加された | ProductAction.AddToWishlist |
| アイテムがウィッシュリストから削除された | ProductAction.RemoveFromWishlist |
| チェックアウトフローが開始された | ProductAction.Checkout |
| チェックアウトオプションが選択された | ProductAction.CheckoutOption |
| 注文が確認された | ProductAction.Purchase |
| 注文が返金された | ProductAction.Refund |
コマースイベントを追跡するには、3つのステップが必要です:
1Define the product#
製品の名前、SKU、および価格を使用してProductを作成します。ビルダーを使用して追加のフィールドを設定します。
var product = new Product(
name: "Double Room - Econ Rate",
sku: "econ-1",
price: 100.00
)
{
Quantity = 4,
Category = "room",
Brand = "lodge-o-rama",
Variant = "standard"
};
2Summarize the transaction#
TransactionAttributes、Purchase、および Checkout イベント用の CheckoutOption オブジェクトを作成します。該当する場合は、配送情報とクーポンコードを含めます — 注文レベルのクーポンはここに含まれ、個々の製品には含まれません。
var transactionAttributes = new TransactionAttributes("ORDER-12345")
{
Revenue = 149.99,
Tax = 12.50,
Shipping = 5.99,
CouponCode = "SUMMER20"
};
3Log the commerce event#
上記の表から製品アクション定数を使用して CommerceEvent を作成し、transactionAttributes を添付してログを記録します。ログに記録したい顧客のアクションを選択します:
顧客が製品詳細ページを開いたときにログを記録します。
var product = new Product(
name: "Trail Runner v3",
sku: "SKU-001",
price: 129.95
)
{
Quantity = 1,
Category = "shoes"
};
var commerceEvent = new CommerceEvent(ProductAction.ViewDetail, product)
{
Currency = "USD"
};
MParticle.Instance.LogCommerceEvent(commerceEvent);
顧客がカートに商品を追加したときにログを記録します。
var product = new Product(
name: "Trail Runner v3",
sku: "SKU-001",
price: 129.95
)
{
Quantity = 1
};
var commerceEvent = new CommerceEvent(ProductAction.AddToCart, product)
{
Currency = "USD"
};
MParticle.Instance.LogCommerceEvent(commerceEvent);
顧客がカートから商品を削除したときにログを記録します。
var product = new Product(
name: "Trail Runner v3",
sku: "SKU-001",
price: 129.95
)
{
Quantity = 1 // units removed
};
var commerceEvent = new CommerceEvent(ProductAction.RemoveFromCart, product)
{
Currency = "USD"
};
MParticle.Instance.LogCommerceEvent(commerceEvent);
顧客がチェックアウトフローに入ったときにログを記録します。カートの合計と注文レベルのクーポンを含むトランザクション概要とすべてのカート商品を送信します。
var product1 = new Product(name: "Trail Runner v3", sku: "SKU-001", price: 129.95) { Quantity = 1 };
var product2 = new Product(name: "Cushion Insole", sku: "SKU-002", price: 19.95) { Quantity = 2 };
var transactionAttributes = new TransactionAttributes("ORDER-12345")
{
Revenue = 169.85,
CouponCode = "SUMMER20"
};
var commerceEvent = new CommerceEvent(ProductAction.Checkout, product1)
{
Currency = "USD",
TransactionAttributes = transactionAttributes
};
commerceEvent.AddProduct(product2);
MParticle.Instance.LogCommerceEvent(commerceEvent);
顧客が配送ステップを完了したときにログを記録します。CheckoutOption を "shipping" に設定し、配送選択をカスタム属性として渡します。
var product1 = new Product(name: "Trail Runner v3", sku: "SKU-001", price: 129.95) { Quantity = 1 };
var product2 = new Product(name: "Cushion Insole", sku: "SKU-002", price: 19.95) { Quantity = 2 };
var commerceEvent = new CommerceEvent(ProductAction.CheckoutOption, product1)
{
Currency = "USD",
CheckoutOption = "shipping",
CustomAttributes = new Dictionary<string, string>
{
{ "shippingmethod", "express" },
{ "zipcode", "94103" },
{ "country", "US" },
{ "totalprice", "169.85" }
}
};
commerceEvent.AddProduct(product2);
MParticle.Instance.LogCommerceEvent(commerceEvent);
顧客が支払いステップを完了したときにログを記録します。CheckoutOption を "payment" に設定し、選択された支払い方法をカスタム属性として渡します。
var product1 = new Product(name: "Trail Runner v3", sku: "SKU-001", price: 129.95) { Quantity = 1 };
var product2 = new Product(name: "Cushion Insole", sku: "SKU-002", price: 19.95) { Quantity = 2 };
var commerceEvent = new CommerceEvent(ProductAction.CheckoutOption, product1)
{
Currency = "USD",
CheckoutOption = "payment",
CustomAttributes = new Dictionary<string, string>
{
{ "paymenttype", "credit_card" },
{ "payment_method", "visa" },
{ "paymentServiceProvider", "stripe" },
{ "ccbin", "424242" },
{ "totalprice", "169.85" }
}
};
commerceEvent.AddProduct(product2);
MParticle.Instance.LogCommerceEvent(commerceEvent);
注文が確認されたときにログを記録します。注文、収益、税金、配送、および注文レベルのクーポンを識別するトランザクション概要と完全なカートを送信します。
var product1 = new Product(name: "Trail Runner v3", sku: "SKU-001", price: 129.95) { Quantity = 1 };
var product2 = new Product(name: "Cushion Insole", sku: "SKU-002", price: 19.95) { Quantity = 2 };
var transactionAttributes = new TransactionAttributes("ORDER-10482")
{
Revenue = 169.85,
Tax = 14.20,
Shipping = 5.99,
CouponCode = "SUMMER20"
};
var commerceEvent = new CommerceEvent(ProductAction.Purchase, product1)
{
Currency = "USD",
TransactionAttributes = transactionAttributes
};
commerceEvent.AddProduct(product2);
MParticle.Instance.LogCommerceEvent(commerceEvent);
注文(またはその中の行)が返金されたときにログを記録します。返金される商品のみを送信し、元の注文IDを参照するトランザクション概要を送信します。
var refundedProduct = new Product(
name: "Trail Runner v3",
sku: "SKU-001",
price: 129.95
)
{
Quantity = 1 // units refunded
};
var transactionAttributes = new TransactionAttributes("ORDER-10482") // original order id
{
Revenue = 129.95 // refunded amount
};
var commerceEvent = new CommerceEvent(ProductAction.Refund, refundedProduct)
{
Currency = "USD",
TransactionAttributes = transactionAttributes
};
MParticle.Instance.LogCommerceEvent(commerceEvent);
同じ構造がすべての製品アクション定数に適用されます — ログに記録している顧客の行動に一致するアクションに ProductAction.Purchase を置き換えます。製品アクションタイプの完全なリストについては、上記の表を参照してください。
LogEvent を使用してカスタムイベントを追跡し、イベント名、イベントタイプ、およびオプションのカスタム属性を渡します。
カスタムイベントタイプを表示
| タイプ | 使用用途 |
|---|---|
EventType.Navigation | アプリ内でのユーザーのナビゲーションフローや画面遷移。 |
EventType.Location | 位置情報に基づくインタラクションや移動。 |
EventType.Search | 検索クエリや検索関連のアクション。 |
EventType.Transaction | 金融取引や購入関連の活動。 |
EventType.UserContent | レビュー、コメント、投稿などのユーザー生成コンテンツ。 |
EventType.UserPreference | ユーザー設定、好み、カスタマイズの選択。 |
EventType.Social | ソーシャルメディアのインタラクションや共有活動。 |
EventType.Other | 上記のカテゴリに当てはまらないもの。 |
MParticle.Instance.LogEvent(
"video_watched",
EventType.Navigation,
new Dictionary<string, string>()
{
{ "category", "Destination Intro" },
{ "title", "Paris" }
}
);
6. Show a Placement#
Roktがコンテンツを表示する支払い画面や確認画面ごとに、SelectPlacementsを呼び出します。画面タイプとテストまたは本番環境であるかを指定するために、以下のページ識別子のいずれかを含めてください:
stg.rokt.conf: A confirmation screen in a staging (or testing) environment.prod.rokt.conf: A confirmation screen in a production environment.stg.rokt.payments: A payments screen in a staging (or testing) environment.prod.rokt.payments: A payments screen in a production environment.
画面が読み込まれた時点で、すべての関連属性が利用可能になったらすぐにSelectPlacementsを呼び出します。最低限、email、firstname、lastname、billingzipcode、およびconfirmationrefを渡します。完全なリストについてはPlacement attributesを参照してください。
Pay+プレースメントの場合、各画面でのSelectPlacements呼び出しにpaymenttypeとpaymentServiceProviderを含めます。paymentServiceProviderは支払い画面で利用可能な支払い方法を伝え、paymenttypeはユーザーが支払った方法を伝えます。
配置属性配置属性 への直接リンク
これらの属性を attributes 辞書に SelectPlacements として渡します。常に最新の値を提供してください — ここで渡された属性は、以前の SetUserAttribute 呼び出しを上書きします。
すべての配置属性を表示
| フィールド | 型 | 説明 |
|---|---|---|
email | string | 顧客のメールアドレス(ハッシュ化されていない)。アイデンティティ解決に使用されます。 |
firstname | string | 顧客の名。パーソナライズに使用されます。 |
lastname | string | 顧客の姓。パーソナライズに使用されます。 |
mobile | string | E.164形式の顧客の携帯電話番号。アイデンティティ解決に使用されます。 |
confirmationref | string | 注文/確認参照番号。関連性と重複排除に使用されます。 |
currency | string | 取引通貨(ISO 4217、例: USD, GBP, AUD)。関連性に使用されます。 |
country | string | ISO 3166-1 alpha-2 国コード。適格性と関連性に使用されます。 |
language | string | 顧客の希望言語(ISO 639-1)。関連性に使用されます。 |
totalprice | decimal | 税金と送料を含むカートの合計値。関連性に使用されます。 |
amount | string | 税金と送料を含まないカートの小計。totalprice とは異なります。関連性に使用されます。 |
couponCode | string | 注文に適用されたプロモーションコード(ある場合)。関連性に使用されます。 |
newcustomer | boolean | 初回購入者であるかどうか。関連性に使用されます。 |
customertype | string | guest または logged_in。関連性に使用されます。 |
value | decimal | 顧客の累積購入価値(例: "2340.00")。関連性に使用されます。 |
subscriptionstatus | string | 該当する場合のサブスクリプション状態(active, trial, churned, paused, none)。関連性と適格性に使用されます。 |
customersegment | string | パートナー内部のセグメンテーション(例: vip, at_risk, new, reactivated)。関連性に使用されます。 |
paymenttype | string | 選択された支払い方法(credit_card, paypal, apple_pay など)。Pay+の適格性に使用されます。 |
paymentServiceProvider | string | ページで受け入れられる支払い方法のカンマ区切りリスト(例: applepay,paypal,cardpayment)。値は小文字でスペースを含まない必要があります。受け入れられる値の完全なリストについてはPayment Service Providerを参照してください。Pay+ の適格性に使用されます。 |
ccbin | string | クレジットカードのBIN(6-8桁)。関連性に使用されます。 |
billingname | string | 請求名。アイデンティティ解決に使用されます。 |
billingaddress1 | string | 請求先の住所。アイデンティティ解決と関連性に使用されます。 |
billingaddress2 | string | 請求先のアパート/ユニット。アイデンティティ解決に使用されます。 |
billingcity | string | 請求先の市区町村。関連性に使用されます。 |
billingstate | string | 請求先の州または省。関連性に使用されます。 |
billingzipcode | string | 請求先の郵便番号。アイデンティティ解決と関連性に使用されます。 |
shippingmethod | string | 選択された配送方法(standard、express、next_day)。関連性に使用されます。 |
shippingname | string | 配送名。関連性に使用されます。 |
shippingaddress1 | string | 配送先の住所。関連性に使用されます。 |
shippingcity | string | 配送先の市区町村。関連性に使用されます。 |
shippingstate | string | 配送先の州または省。関連性に使用されます。 |
shippingzipcode | string | 配送先の郵便番号。関連性に使用されます。 |
shippingcountry | string | 配送先の国(ISO 3166-1 alpha-2)。関連性に使用されます。 |
cartItems | array | カートラインオブジェクトの構造化された配列。関連性に使用されます。 |
adsexperience | string | Shoppable Ads エクスペリエンスを意図的にターゲットにする場合は "shoppable" を渡します。 |
オーバーレイプレースメントは、Rokt が管理するコンテナ内で確認画面の上にレンダリングされ、アプリの既存のレイアウトに変更を加える必要はありません。オーバーレイプレースメントを挿入するには、確認画面が読み込まれた後に SelectPlacements を呼び出します:
using mParticle.MAUI;
var attributes = new Dictionary<string, string>
{
// Identity
["email"] = "j.smith@example.com",
["firstname"] = "Jenny",
["lastname"] = "Smith",
["mobile"] = "+13125551515",
// Transaction
["confirmationref"] = "54321",
["currency"] = "USD",
["country"] = "US",
["language"] = "en",
["totalprice"] = "149.99",
["couponCode"] = "SUMMER20",
// Customer context
["newcustomer"] = "false",
["customertype"] = "logged_in",
["value"] = "2340.00",
["subscriptionstatus"] = "active",
["customersegment"] = "vip",
// Payment (include paymenttype and paymentServiceProvider for Pay+)
["paymenttype"] = "credit_card",
["paymentServiceProvider"] = "cardpayment",
["ccbin"] = "411112",
// Billing address
["billingaddress1"] = "123 Main St",
["billingcity"] = "Brooklyn",
["billingstate"] = "NY",
["billingzipcode"] = "11201",
// Shipping
["shippingmethod"] = "express",
["shippingaddress1"] = "175 Varick St",
["shippingcity"] = "New York",
["shippingstate"] = "NY",
["shippingzipcode"] = "10014",
["shippingcountry"] = "US"
};
MParticle.Instance.Rokt.SelectPlacements(
identifier: "RoktExperience",
attributes: attributes
);
埋め込みプレースメントは、アプリ内の固定位置にインラインでレンダリングされ、コントロールできます(例: カート画面の支払いオプションの上)。Thanks と Pay+ の両方が埋め込みプレースメントを使用しますが、Pay+ は埋め込みプレースメントを使用する必要があります。
1Register the RoktEmbeddedView handler#
アプリのスタートアップクラスで、RoktEmbeddedViewのためにMAUIハンドラーを設定し、SDK+がレイアウト内に埋め込まれたビューをレンダリングできるようにします。
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler(typeof(RoktEmbeddedView), typeof(RoktEmbeddedViewHandler));
});
return builder.Build();
}
}
2Add RoktEmbeddedView to your XAML layout#
RoktEmbeddedViewをXAMLレイアウトに追加し、プレースメントをレンダリングしたい位置に配置します。x:Name(ここではLocation1)は、コードビハインドから参照するためのものです。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:sdk="clr-namespace:mParticle.MAUI;assembly=mParticle.Maui.Sdk"
x:Class="SampleApp.MainPage">
<VerticalStackLayout>
<sdk:RoktEmbeddedView
x:Name="Location1"/>
</VerticalStackLayout>
</ContentPage>
3Call SelectPlacements and subscribe to events#
コードビハインドから、Events(ロード状態、準備完了、インタラクション、完了、失敗)にプレースメントイベントをサブスクライブし、SelectPlacementsを呼び出して、RoktEmbeddedViewをx:NameでembeddedViews辞書に渡します。
using mParticle.MAUI;
var attributes = new Dictionary<string, string>
{
["email"] = "j.smith@example.com",
["firstname"] = "Jenny",
["lastname"] = "Smith",
["billingzipcode"] = "11201",
["confirmationref"] = "54321"
};
MParticle.Instance.Rokt.Events("RoktExperience", roktEvent =>
{
switch (roktEvent.GetType().Name)
{
case "RoktShowLoadingIndicator":
Console.WriteLine("Rokt is loading...");
break;
case "RoktPlacementReady":
Console.WriteLine("Placement is ready.");
break;
case "RoktPlacementInteractive":
Console.WriteLine("Placement is interactive.");
break;
case "RoktPlacementCompleted":
Console.WriteLine("Placement completed.");
break;
case "RoktPlacementFailure":
Console.WriteLine("Placement failed or no fill.");
break;
default:
Console.WriteLine($"Unhandled event: {roktEvent.GetType().Name}");
break;
}
});
MParticle.Instance.Rokt.SelectPlacements(
identifier: "RoktExperience",
attributes: attributes,
embeddedViews: new Dictionary<string, RoktEmbeddedView>()
{
{ "RoktEmbedded1", Location1 }
}
);
Pay+プレースメントの場合、各画面でのSelectPlacements呼び出しにpaymenttypeとpaymentServiceProviderを含めます。paymentServiceProviderは、支払い画面で利用可能な支払い方法を伝え、paymenttypeは、ユーザーがどの方法で支払ったかを伝えます。
インタースティシャルプレースメントは、支払い画面と確認画面の間にレンダリングされ、顧客が追加の製品を購入できるようにします。インタースティシャルプレースメントはShoppable Adsで使用されます。
インタースティシャルプレースメントは、MAUI SDK+ではiOSのみでサポートされています。このSDK+のAndroidパスはインタースティシャルプレースメントをサポートしていません。すべてのインタースティシャルプレースメントコードを#if __IOS__条件付きコンパイルブロックにスコープします。
iOSでは、インタースティシャルプレースメントは、支払い拡張機能を登録した後に専用のSelectShoppableAdsメソッドを使用します(Apple Payの設定(iOSのみ)を参照)。CartItemInstantPurchaseと関連するイベントは、Events APIにおいて、Shoppable Adsの購入フロー中に発火します。Placement attributesで説明されている完全な属性セットを渡します。特に、Shoppable Adsの注文履行をサポートするために、配送先住所の詳細を含めます。
#if __IOS__
using mParticle.MAUI;
var attributes = new Dictionary<string, string>
{
// Identity
["email"] = "j.smith@example.com",
["firstname"] = "Jenny",
["lastname"] = "Smith",
["mobile"] = "+13125551515",
// Transaction
["confirmationref"] = "54321",
["currency"] = "USD",
["country"] = "US",
["language"] = "en",
["totalprice"] = "149.99",
["amount"] = "137.50",
["couponCode"] = "SUMMER20",
// Customer context
["newcustomer"] = "false",
["customertype"] = "logged_in",
["value"] = "2340.00",
// Payment
["paymenttype"] = "credit_card",
["paymentServiceProvider"] = "cardpayment",
["ccbin"] = "411112",
// Billing address
["billingaddress1"] = "123 Main St",
["billingcity"] = "Brooklyn",
["billingstate"] = "NY",
["billingzipcode"] = "11201",
// Shipping address (required for Shoppable Ads order fulfillment)
["shippingmethod"] = "express",
["shippingaddress1"] = "175 Varick St",
["shippingcity"] = "New York",
["shippingstate"] = "NY",
["shippingzipcode"] = "10014",
["shippingcountry"] = "US"
};
MParticle.Instance.Rokt.SelectShoppableAds(
identifier: "RoktExperience",
attributes: attributes,
config: null
);
#endif
アプリに配送先住所の詳細がない場合(例:チケットやデジタル商品購入の場合)、代わりに請求先住所の詳細を渡します。Roktは、購入を完了する前に顧客が配送先住所を確認または編集できるUIを提供します。
オプション機能オプション機能 への直接リンク
| 機能 | 目的 |
|---|---|
MParticle.Instance.Rokt.Close() | オーバーレイプレースメントを自動的に閉じます。 |
追加設定追加設定 への直接リンク
RoktConfigなどのオプションパラメータを渡して、プレースメントUIをカスタマイズします(例:ダーク/ライトモード、キャッシング)。
using mParticle.MAUI;
var roktConfig = new RoktConfig()
{
ColorMode = RoktConfig.RoktColorMode.Light
};
MParticle.Instance.Rokt.SelectPlacements(
identifier: "RoktExperience",
attributes: attributes,
config: roktConfig
);
識別子RoktExperienceまたは埋め込み識別子RoktEmbedded1を異なる値に更新したい場合は、Roktアカウントマネージャーに連絡して、Roktプレースメントが一貫して設定されていることを確認してください。
Events APIEvents API への直接リンク
SDK+は、MParticle.Instance.Rokt APIを通じて配置のライフサイクルイベントを提供します。
Eventsを使用して、配置識別子ごとにサブスクライブし、読み込み状態、準備完了、インタラクション、完了、および失敗に応答します。
void HandleRoktEvent(object roktEvent)
{
switch (roktEvent.GetType().Name)
{
case "RoktShowLoadingIndicator":
Console.WriteLine("Rokt is loading...");
break;
case "RoktHideLoadingIndicator":
Console.WriteLine("Rokt finished loading.");
break;
case "RoktPlacementReady":
Console.WriteLine("Placement is ready.");
break;
case "RoktPlacementInteractive":
Console.WriteLine("Placement is interactive.");
break;
case "RoktPositiveEngagement":
case "RoktFirstPositiveEngagement":
Console.WriteLine("User positively engaged.");
break;
case "RoktPlacementCompleted":
Console.WriteLine("Placement completed.");
break;
case "RoktPlacementFailure":
Console.WriteLine("Placement failed or no fill.");
break;
default:
Console.WriteLine($"Unhandled event: {roktEvent.GetType().Name}");
break;
}
}
MParticle.Instance.Rokt.Events("RoktExperience", roktEvent =>
{
HandleRoktEvent(roktEvent);
});
標準イベント標準イベント への直接リンク
すべての標準イベントを表示
| イベント | 説明 | パラメータ |
|---|---|---|
| ShowLoadingIndicator | SDK+がRoktバックエンドを呼び出す前にトリガーされます。 | |
| HideLoadingIndicator | SDK+がRoktバックエンドから成功または失敗を受け取ったときにトリガーされます。 | |
| PlacementInteractive | 配置がレンダリングされ、インタラクション可能になったときにトリガーされます。 | placementId: string |
| PlacementReady | 配置が表示準備が整ったが、まだコンテンツがレンダリングされていないときにトリガーされます。 | placementId: string |
| OfferEngagement | ユーザーがオファーに関与したときにトリガーされます。 | placementId: string |
| PositiveEngagement | ユーザーがオファーに積極的に関与したときにトリガーされます。 | placementId: string |
| FirstPositiveEngagement | ユーザーが初めてオファーに積極的に関与したときにトリガーされます。 | placementId: string, fulfillmentAttributes: Dictionary<string, string> |
| OpenUrl | ユーザーがパートナーアプリに送信するように設定されたURLを押したときにトリガーされます。 | placementId: string, url: string |
| PlacementClosed | ユーザーが配置を閉じたときにトリガーされます。 | placementId: string |
| PlacementCompleted | オファーの進行が終了し、表示するオファーがもうない場合にトリガーされます。また、キャッシュがヒットしたが、以前に却下されたために取得されたプレースメントが表示されない場合にもトリガーされます。 | placementId: string |
| PlacementFailure | 何らかの失敗によりプレースメントを表示できなかった場合、または表示するプレースメントがない場合にトリガーされます。 | placementId: string (optional) |
| CartItemInstantPurchase | ユーザーによってカタログアイテムの購入が開始されたときにトリガーされます。 | placementId: string, cartItemId: string, catalogItemId: string, currency: string, description: string, linkedProductId: string, totalPrice: double, quantity: int, unitPrice: double |
7. Configure Apple Pay (iOS only)#
iOSでShoppable Adsを使用するにはApple Payが必要です。Shoppable Adsを使用しない場合、このステップをスキップしてください。
支払い拡張機能を登録する前に、Apple PayのマーチャントIDを作成し、Xcodeプロジェクトを設定し、支払い処理証明書を生成してください。
Apple Pay — iOS setupの手順に従い、その後iOS固有のプラットフォームコードでRoktPaymentExtensionを登録します。MAUIプロジェクトでは、これをiOSプラットフォームのAppDelegate.cs(またはMauiProgram.csの#if __IOS__ブロック内)に配置し、MParticle.Instance.Initialize(options)の後、SelectPlacementsやSelectShoppableAdsの呼び出しの前に呼び出します。
#if __IOS__
// iOS only: register after MParticle.Instance.Initialize(options),
// before SelectPlacements/SelectShoppableAds.
RoktPaymentExtension.Register("merchant.com.yourapp.rokt");
#endif
RoktPaymentExtensionは、MParticle.Instance.Initialize(options)の後、およびSelectPlacementsやSelectShoppableAdsの呼び出しの前に登録する必要があります。順序が正しくないと、Apple Payが正しく機能しません。
RoktPaymentExtensionの登録に関する正確なC# APIは、MAUIバインディングのバージョンによって異なる場合があります。上記のメソッドシグネチャがNuGetパッケージと一致しない場合は、NuGetのリリースノートで同等の呼び出しを確認するか、バインディング固有のガイダンスについてRoktサポートにお問い合わせください。
8. Appendix#
付録 A: アプリケーション設定付録 A: アプリケーション設定 への直接リンク
アプリケーションは、RoktConfig を通じて設定を渡すことができ、MAUI SDK+ はシステムのデフォルトではなく、アプリのカスタム設定を使用します。
ColorMode オブジェクトColorMode オブジェクト への直接リンク
| 値 | 説明 |
|---|---|
| Light | アプリケーションはライトモードです |
| Dark | アプリケーションはダークモードです |
| System | アプリケーションはシステムのカラーモードをデフォルトにします |
var roktConfig = new RoktConfig()
{
ColorMode = RoktConfig.RoktColorMode.Light
};
MParticle.Instance.Rokt.SelectPlacements(
identifier: "RoktExperience",
attributes: attributes,
config: roktConfig
);
CacheConfig オブジェクトCacheConfig オブジェクト への直接リンク
| パラメータ | 説明 |
|---|---|
CacheDurationInSeconds | Rokt SDK+ がエクスペリエンスをキャッシュする秒数のオプションの期間。最大許容値は90分です。提供されないか無効な場合、デフォルトは90分です。 |
CacheAttributes | キャッシュキーとして使用するオプションの属性。null の場合、SelectPlacements で送信されたすべての属性がキャッシュキーとして使用されます。 |
var roktConfig = new RoktConfig()
{
CacheConfig = new CacheConfig()
{
CacheDurationInSeconds = 1200,
CacheAttributes = new Dictionary<string, string>()
{
{ "email", "j.smith@example.com" },
{ "orderNumber", "123" }
}
}
};
MParticle.Instance.Rokt.SelectPlacements(
identifier: "RoktExperience",
attributes: attributes,
config: roktConfig
);
EdgeToEdgeDisplay (Android のみ)EdgeToEdgeDisplay (Android のみ) への直接リンク
| 値 | 説明 |
|---|---|
true (デフォルト) | アプリケーションはエッジトゥエッジディスプレイモードをサポートします |
false | アプリケーションはエッジトゥエッジディスプレイモードをサポートしません |
この設定を Android のみにスコープするには、#if __ANDROID__ ブロックを使用します:
#if __ANDROID__
var roktConfig = new RoktConfig()
{
EdgeToEdgeDisplay = true
};
MParticle.Instance.Rokt.SelectPlacements(
identifier: "RoktExperience",
attributes: attributes,
config: roktConfig
);
#endif
付録 B: MAUI 宣言型 UI サポート付録 B: MAUI 宣言型 UI サポート への直接リンク
MAUI SDK+ は、XML ベースのレイアウト (RoktEmbeddedView in XAML) とコードビハインドの配置統合の両方をサポートしています。XAML での埋め込み配置の場合、RoktEmbeddedViewHandler を MauiProgram.CreateMauiApp() に登録し、コードビハインドでビューをその x:Name で参照します(Embedded placements を参照)。
現時点では、MAUI に Jetpack Compose (RoktLayout) や SwiftUI (MPRoktLayout) に相当するものはありません。埋め込み配置には XML + コードビハインドパターンを使用してください。
付録 C: エラーハンドリング付録 C: エラーハンドリング への直接リンク
IDSync API はアプリの状態にとって中心的な役割を果たすことを意図しており、高速で高可用性を備えています。アプリがインターネット接続なしでユーザーのログイン、ログアウト、または状態の変更を防ぐのと同様に、これらの API を一貫したユーザー状態を維持するためのゲート操作として扱ってください。SDK+ は API コールを自動的に再試行しませんが、ビジネスロジックに従って再試行できるコールバック API を提供します。
エラーハンドリングを実装しない場合、大規模なデータ整合性の問題が発生する可能性があります。
失敗リスナーは errorResponse オブジェクトを受け取ります。HttpCode プロパティを使用して原因を特定し、再試行するかどうかを決定します。
Android のエラーハンドリングAndroid のエラーハンドリング への直接リンク
Android では、IdentityApi.UNKNOWN_ERROR はクライアント側の失敗(デバイスがオフラインまたはクライアント側のタイムアウト)を示します — リクエストを再試行してください。HTTP 429 (IdentityApi.THROTTLE_ERROR) はリクエストがレート制限されたことを意味します — 指数バックオフで再試行してください。他の HTTP エラーコードは実装またはサーバーの問題を示しており、ログに記録して調査する必要があります。
#if __ANDROID__
MParticle.Instance.Identity.Identify(identifyRequest)
.AddFailureListener(errorResponse =>
{
if (errorResponse.HttpCode == IdentityApi.UnknownError)
{
// Device is likely offline or client-side timeout — retry the request
}
else if (errorResponse.HttpCode == 429)
{
// Throttled — retry with exponential backoff
}
else
{
// Log errorResponse.HttpCode and investigate — likely an implementation issue
}
})
.AddSuccessListener(result =>
{
// Proceed with the identified user
});
#endif
iOS のエラーハンドリングiOS のエラーハンドリング への直接リンク
iOS では、失敗リスナーの HttpCode はネイティブ iOS SDK+ の MPIdentityErrorResponseCode 値にマッピングされます。ネットワーク障害 (clientNoConnection, clientSideTimeout) はすぐに再試行する必要があります。スロットルエラー (HTTP 429、retry に対応) はバックオフで再試行する必要があります。requestInProgress は別の IDSync コールが進行中であることを意味します — これが頻繁に発生する場合は実装を確認し、その後再試行してください。他のすべてのコードは通常、実装の問題を示します。errorResponse の詳細を確認して診断してください。
#if __IOS__
MParticle.Instance.Identity.Identify(identifyRequest)
.AddFailureListener(errorResponse =>
{
if (errorResponse.HttpCode == IdentityApi.UnknownError)
{
// clientNoConnection or clientSideTimeout — device is offline or timed out, retry the request
}
else if (errorResponse.HttpCode == 429)
{
// Throttled (MPIdentityErrorResponseCodeRetry) — retry with exponential backoff
}
else if (errorResponse.HttpCode == (int)IdentityApi.RequestInProgress)
{
// Another IDSync request is already in progress — inspect implementation frequency, then retry
}
else
{
// Log errorResponse details and investigate — likely an implementation issue
}
})
.AddSuccessListener(result =>
{
// Proceed with the identified user
});
#endif
上記のC#定数名 (IdentityApi.UnknownError, IdentityApi.RequestInProgress) は、MAUIバインディングレイヤーを反映しています。NuGetバージョンが異なる定数名を公開している場合、それらは基盤となるiOSのMPIdentityErrorResponseCode値にマッピングされます:
| MAUI C#定数 | iOS MPIdentityErrorResponseCode |
|---|---|
IdentityApi.UnknownError | clientNoConnection, clientSideTimeout, または unknown |
IdentityApi.RequestInProgress | requestInProgress |
| HTTP 429 | retry (スロットル) |
付録D: ウェブからネイティブへのセッションIDの受け渡し付録D: ウェブからネイティブへのセッションIDの受け渡し への直接リンク
ユーザージャーニーがウェブとネイティブプラットフォームの両方にまたがる場合、Web SDK+からMAUI SDK+にセッションIDを渡すことで一貫したRoktセッションを維持できます。これは、ユーザーがWebViewでアクションを完了(例: 支払いページ)し、確認のためにネイティブアプリに戻るハイブリッドフローに役立ちます。
Web SDK+からセッションIDを取得するWeb SDK+からセッションIDを取得する への直接リンク
selectPlacementsを呼び出した後、セッションIDは選択コンテキストで利用可能です:
const selection = await launcher.selectPlacements({
identifier: "checkout",
attributes: {
email: "user@example.com",
// ... other attributes
}
});
const sessionId = await selection.context.sessionId;
The session ID is a unique GUID assigned to the current user journey. It is useful for debugging and for correlating a user's activity across your web and native surfaces.
ディープリンクを介してネイティブアプリに渡すディープリンクを介してネイティブアプリに渡す への直接リンク
ディープリンクを使用してネイティブアプリにセッションIDを渡します:
const deepLink = `myapp://confirmation?sessionId=${encodeURIComponent(sessionId)}`;
window.location.href = deepLink;
セッションIDの設定セッションIDの設定 への直接リンク
ディープリンクからセッションIDを抽出し、SelectPlacementsを呼び出す前にSDK+に渡します。
// Extract sessionId from the incoming deep link URI
// and set it on the Rokt SDK+ before calling SelectPlacements
var uri = new Uri(deepLinkUrl);
var query = System.Web.HttpUtility.ParseQueryString(uri.Query);
var sessionId = query["sessionId"];
if (!string.IsNullOrEmpty(sessionId))
{
MParticle.Instance.Rokt.SetSessionId(sessionId);
}
// Proceed with your confirmation flow
注意事項注意事項 への直接リンク
- セッションが使用されるようにするため、
SetSessionIdをSelectPlacementsの前に呼び出してください。 - 空の文字列は無視され、セッションは更新されません。
- クエリパラメータとして渡す際には、常にセッションIDをURLエンコードしてください。
9. Test Your Integration#
SDK+が正しく初期化され、イベントが正しくログされることを確認するには:
1Enable verbose SDK+ logging#
初期化前に詳細なSDK+ログを有効にして、送信されている内容を確認できるようにします。
#if __ANDROID__
MParticle.Instance.SetLogLevel(LogLevel.Verbose);
#elif __IOS__
MParticle.Instance.SetLogLevel(LogLevel.Verbose);
#endif
2Build and run against a development key#
アプリをビルドして実行し、options.Environment = mParticle.MAUI.Environment.Developmentを設定します。
3Trigger SelectPlacements#
配置がレンダリングされるべき画面でSelectPlacementsをトリガーし、配置がロードされることを確認します。
4Verify events#
イベントがログされ、identifyRequest呼び出しが成功することを確認します。
トラブルシューティングトラブルシューティング への直接リンク
プレースメントがレンダリングされない、またはイベントが表示されない場合は、デバイスコンソールでRokt SDK+のエラーを確認してください。一般的な問題:
初期化エラー初期化エラー への直接リンク
- プラットフォーム固有のブロック内のキーとシークレットが、Roktアカウントマネージャーから提供された値と一致していることを確認してください。
MParticle.Instance.Initialize(options)が、SelectPlacementsまたはLogEventの呼び出しの前に実行されることを確認してください。RoktKit.Register()がMParticle.Instance.Initialize(options)の前に呼び出されることを確認してください。
アイデンティティエラーアイデンティティエラー への直接リンク
AddFailureListener コールバックが発火した場合、エラーコードと再試行ガイダンスについてはエラーハンドリングを参照してください。エラーハンドリングがないと、大規模なデータ整合性の問題が発生する可能性があります。
プレースメントがレンダリングされないプレースメントがレンダリングされない への直接リンク
- プレースメントの
identifier(例:RoktExperience)が、Roktアカウントマネージャーが設定したものと一致していることを確認してください。 - 埋め込みプレースメントの場合、埋め込みビューの識別子(例:
RoktEmbedded1)がレイアウト設定と一致しており、RoktEmbeddedViewHandlerがMauiProgramに登録されていることを確認してください。 - 属性辞書に少なくとも
email、firstname、lastname、billingzipcode、confirmationrefが含まれていることを確認してください。