メインコンテンツまでスキップ

SDK マイグレーションガイド

このページでは、以下にリストされたバージョン移行、パッケージ変更、および API 置換にわたって既存の Rokt SDK および SDK+ 統合を更新する方法を説明します。

mParticle Apple SDK 9.0 (iOS)mParticle Apple SDK 9.0 (iOS) への直接リンク

iOS アプリで mParticle Apple SDK(および Rokt キット)を 8.x から 9.x にアップグレードする場合、いくつかの重大な変更が適用されます。

型システム: MPRokt 型 → RoktContracts型システム: MPRokt 型 → RoktContracts への直接リンク

9.0 の最大の変更点は、すべての MPRokt* ラッパー型が削除されたことです。SDK は現在、RoktContracts パッケージからの型を直接公開しています。Swift では、単一の import mParticle_Apple_SDK で、すべての RoktEvent 型にアクセスできます — 追加のインポートは必要ありません。Objective-C では、mParticle インポートの横に @import RoktContracts; を追加します。

旧 (8.x)新 (9.0)
MPRoktEventRoktEvent
MPRoktConfigRoktConfig (ビルダーパターンを使用)
MPRoktEmbeddedViewRoktEmbeddedView
MPRoktEventCallback削除 — onEvent クロージャを使用
MPColorModeLight / MPColorModeDarkRoktColorModeLight / RoktColorModeDark (ObjC) または .light / .dark (Swift)
MPRoktEvent.MPRoktPlacementReadyRoktEvent.PlacementReady
MPRoktEvent.MPRoktPlacementClosedRoktEvent.PlacementClosed
MPRoktEvent.MPRoktEmbeddedSizeChangedRoktEvent.EmbeddedSizeChanged
MPRoktEvent.MPRoktCartItemInstantPurchaseRoktEvent.CartItemInstantPurchase
イベントプロパティ: placementIdidentifier

コールバック → onEventコールバック → onEvent への直接リンク

MPRoktEventCallback クラスと callbacks: パラメータは selectPlacements から削除されました。代わりに onEvent: クロージャを使用してください。

以前 (8.x):

import mParticle_Apple_SDK

let callbacks = MPRoktEventCallback()
callbacks.onLoad = { /* placement loaded */ }
callbacks.onUnLoad = { /* placement unloaded */ }
callbacks.onShouldShowLoadingIndicator = { /* show spinner */ }
callbacks.onShouldHideLoadingIndicator = { /* hide spinner */ }
callbacks.onEmbeddedSizeChange = { (placement, size) in /* resize */ }

MParticle.sharedInstance().rokt.selectPlacements("RoktExperience",
attributes: attributes, embeddedViews: embeddedViews,
config: roktConfig, callbacks: callbacks)

以後 (9.x):

import mParticle_Apple_SDK

MParticle.sharedInstance().rokt.selectPlacements("RoktExperience",
attributes: attributes, embeddedViews: embeddedViews,
config: roktConfig) { event in
switch event {
case is RoktEvent.ShowLoadingIndicator:
// Show spinner
case is RoktEvent.HideLoadingIndicator:
// Hide spinner
case is RoktEvent.PlacementReady:
// Placement loaded
case is RoktEvent.PlacementClosed:
// Placement unloaded
case let sizeEvent as RoktEvent.EmbeddedSizeChanged:
// Resize: use sizeEvent.identifier and sizeEvent.updatedHeight
default:
break
}
}

RoktConfig ビルダーパターンRoktConfig ビルダーパターン への直接リンク

MPRoktConfig の可変プロパティは RoktConfig.Builder に置き換えられました:

以前: let config = MPRoktConfig(); config.colorMode = .light

以後: let config = RoktConfig.Builder().colorMode(.light).build()

グローバルイベントグローバルイベント への直接リンク

すべてのプレースメントからのイベントを購読するための新しい globalEvents: メソッドが利用可能です。これには InitComplete が含まれます:

MParticle.sharedInstance().rokt.globalEvents { event in
if let initEvent = event as? RoktEvent.InitComplete {
print("SDK initialized: \(initEvent.success)")
}
}

その他の重大な変更その他の重大な変更 への直接リンク

  • AppDelegate プロキシ: SDK はもはや自動的に UIApplicationDelegate メッセージをインターセプトしません。プッシュ通知とURL/ユーザーアクティビティイベントをSDKに明示的に転送する必要があります。
  • URLとユーザーアクティビティ: UIScene ライフサイクルとSDKの handleURLContext: および handleUserActivity: メソッドを優先してください。
  • 直接ルーティング: APIリクエストはデフォルトでAPIキーのプレフィックスに基づいて地域のエンドポイントを使用します。App Transport Securityが *.mparticle.com を許可することを確認してください。
  • データベース移行: SDKバージョン8.27.0以前から9.xにアップグレードすると、ローカルデータベースが新規に開始され、保留中のイベントは移行されません。

ショッパブル広告: PaymentKit → PaymentExtensionショッパブル広告: PaymentKit → PaymentExtension への直接リンク

以前に Rokt_Payment_Kit をApple Payに使用していた場合:

パッケージ: Rokt_Payment_Kitパッケージ: RoktPaymentExtension
RoktPaymentKit(applePayMerchantId:)RoktPaymentExtension(applePayMerchantId:urlScheme:)
Rokt.registerPaymentKit(kit)Rokt.registerPaymentExtension(ext, config:)
Rokt.execute(...) for shoppable placementsRokt.selectShoppableAds(...)
Stripe key in kit only直接SDK: stripeKey in config dict. SDK+: stripePublishableKey in mParticle Rokt kit settings

更新されたAPIについては、Shoppable Ads iOS Integration ガイドを参照してください。

RoktStripePaymentExtension → RoktPaymentExtensionRoktStripePaymentExtension → RoktPaymentExtension への直接リンク

暫定的な RoktStripePaymentExtension パッケージを統合した場合、以下のように更新してください:

パッケージ URL: https://github.com/ROKT/rokt-stripe-payment-extension-ioshttps://github.com/ROKT/rokt-payment-extension-ios (旧 URL はリダイレクトされます)
Pod: RoktStripePaymentExtensionRoktPaymentExtension '~> 2.0'
import RoktStripePaymentExtensionimport RoktPaymentExtension
RoktStripePaymentExtension(...)RoktPaymentExtension(...)

RoktPaymentExtension 2.0 の重大な変更RoktPaymentExtension 2.0 の重大な変更 への直接リンク

  • returnURL の削除 — 代わりに単純な urlScheme を渡してください(例: "myapp")。拡張機能が Afterpay / Clearpay の完全なリターン URL を内部で構築します。同じスキームを CFBundleURLTypesInfo.plist で登録してください。
  • handleURLCallback が必要 — リダイレクト URL を SceneDelegate / AppDelegate から MParticle.sharedInstance().rokt.handleURLCallback(with:) (SDK+) または Rokt.handleURLCallback(with:) (Direct SDK) に転送してください。iOS 上での Afterpay / Clearpay および組み込みの PayPal に必要です。

Shoppable Ads の最小バージョン (iOS)Shoppable Ads の最小バージョン (iOS) への直接リンク

機能SDK+ (RoktSDKPlus)Direct (Rokt-Widget)
Shoppable Ads (ベース)9.0+5.0+
Afterpay / Clearpay9.1+5.1+
PayPal、カード転送 (組み込み)9.2+5.2+

また、RoktPaymentExtension '~> 2.0'RoktContracts '~> 2.0' が、Podfile に直接固定されている場合に必要です。

mParticle 9.0.x → 9.1.0 の Rokt 依存関係のバンプ (Afterpay、handleURLCallback、パッケージ名の変更) については、Migrating from 9.0.x to 9.1.0 を参照してください。

公式の完全な移行ガイドについては、Migrating from versions < 9.0.0 を参照してください。


React Native SDK+ 3.0 (react-native-mparticle)React Native SDK+ 3.0 (react-native-mparticle) への直接リンク

React Native アプリで 2.x から 3.0react-native-mparticle をアップグレードする場合、以下の変更が適用されます。

新機能: Shoppable Adsサポート新機能: Shoppable Adsサポート への直接リンク

バージョン3.0では、Shoppable Adsの配置を表示するためのMParticle.Rokt.selectShoppableAds()を導入しました。完全なセットアップ手順については、Shoppable Ads React Native Integrationガイドを参照してください。

注記

React NativeでのShoppable Adsは現在、iOSのみサポートされています。

iOS Podfile依存関係iOS Podfile依存関係 への直接リンク

Shoppable Adsを使用する場合、ios/PodfileにRokt SDK+を追加してください(RoktPaymentExtensionを含む):

pod 'RoktSDKPlus', '~> 9.2'

支払い拡張の登録支払い拡張の登録 への直接リンク

ネイティブiOSコード(AppDelegate)でselectShoppableAdsを呼び出す前に、新しいregisterPaymentExtension呼び出しが必要です。mParticle Rokt kit設定でstripePublishableKeyを設定します—このキットは自動的にRoktに転送します。コード内では、Apple PayのマーチャントIDのみを提供します:

import mParticle_Apple_SDK
import RoktPaymentExtension

if let paymentExt = RoktPaymentExtension(applePayMerchantId: "merchant.com.yourapp.rokt") {
MParticle.sharedInstance().rokt.registerPaymentExtension(paymentExt)
}

新しいShoppable Adsイベント新しいShoppable Adsイベント への直接リンク

以下のイベントは、NativeEventEmitter RoktEventsチャンネルを通じて利用可能です:

イベント説明
CartItemInstantPurchaseInitiated購入フローが開始されました — ユーザーが「購入」をタップしました
CartItemInstantPurchase購入が正常に完了しました
CartItemInstantPurchaseFailure購入が失敗しました
CartItemDevicePayApple Pay / デバイス支払いがトリガーされました
InstantPurchaseDismissalユーザーが購入オーバーレイを閉じました

既存APIへの破壊的変更なし既存APIへの破壊的変更なし への直接リンク

MParticle.Rokt.selectPlacements()および他のすべての既存APIは以前と同様に動作します。


React Native Legacy SDK 5.0 (@rokt/react-native-sdk)React Native Legacy SDK 5.0 (@rokt/react-native-sdk) への直接リンク

@rokt/react-native-sdk4.xから5.0にアップグレードする場合、以下の破壊的変更が適用されます。

破壊的変更: execute()selectPlacements()に名前変更breaking-execute-renamed-to-selectplacements への直接リンク

旧バージョン (4.x)新バージョン (5.0)
Rokt.execute(viewName, attributes, placeholders)Rokt.selectPlacements(identifier, attributes, placeholders)
viewName パラメータidentifier パラメータ

New: selectShoppableAds()new-selectshoppableads への直接リンク

バージョン5.0では、Shoppable Ads配置を表示するためのRokt.selectShoppableAds()を導入しています。

注記

React NativeのShoppable Adsは現在、iOSのみでサポートされています。

iOS Podfile依存関係iOS Podfile依存関係 への直接リンク

Shoppable Adsを使用する場合、支払い拡張機能をios/Podfileに追加してください。Rokt-Widget '~> 5.2'@rokt/react-native-sdkを介して推移的に)とペアリングします。

pod 'RoktPaymentExtension', '~> 2.0'

支払い拡張機能の登録支払い拡張機能の登録 への直接リンク

registerPaymentExtension呼び出しが、selectShoppableAdsを呼び出す前にネイティブiOSコードで必要です。直接SDKパスの場合、Stripeの公開可能キーを明示的に提供する必要があります。

import Rokt_Widget
import RoktPaymentExtension

if let paymentExtension = RoktPaymentExtension(applePayMerchantId: "merchant.com.rokt.sample") {
Rokt.registerPaymentExtension(paymentExtension, config: ["stripeKey": "pk_test_placeholder"])
}

新しいShoppable Adsイベント新しいShoppable Adsイベント への直接リンク

以下のイベントがNativeEventEmitter RoktEventsチャンネルを通じて利用可能になりました。

EventDescription
CartItemInstantPurchaseInitiated購入フローが開始されました — ユーザーが「購入」をタップ
CartItemInstantPurchase購入が正常に完了しました
CartItemInstantPurchaseFailure購入が失敗しました
CartItemDevicePayApple Pay / デバイス支払いがトリガーされました
InstantPurchaseDismissalユーザーが購入オーバーレイを閉じました

Flutter Legacy SDK 5.0 (rokt_sdk)Flutter Legacy SDK 5.0 (rokt_sdk) への直接リンク

rokt_sdk4.xから5.0にアップグレードする場合、以下の破壊的変更が適用されます。

Breaking: execute()selectPlacements()に名前変更breaking-execute-renamed-to-selectplacements-1 への直接リンク

Old (4.x)New (5.0)
RoktSdk.execute(viewName, attributes, onLoad, ...)RoktSdk.selectPlacements(viewName: viewName, attributes: attributes)

削除: コールバックとsetLoggingEnabled()removed-callbacks-and-setloggingenabled への直接リンク

executeの以下のコールバックパラメータが削除されました。

  • onLoad
  • onUnLoad
  • onShouldShowLoadingIndicator
  • onShouldHideLoadingIndicator

RoktSdk.setLoggingEnabled()も削除されました。

すべてのライフサイクルイベントは、現在RoktEvents EventChannelを通じて配信されます。

const EventChannel roktEventChannel = EventChannel('RoktEvents');

roktEventChannel.receiveBroadcastStream().listen((dynamic event) {
switch (event["event"]) {
case "InitComplete":
// SDK initialized
break;
case "PlacementReady":
// Replaces onLoad
break;
case "PlacementClosed":
// Replaces onUnLoad
break;
case "ShowLoadingIndicator":
// Replaces onShouldShowLoadingIndicator
break;
case "HideLoadingIndicator":
// Replaces onShouldHideLoadingIndicator
break;
default:
break;
}
});

イベントプロパティの名前変更: placementIdidentifierevent-property-rename-placementid--identifier への直接リンク

すべてのイベントオブジェクトは、現在 identifier を使用し、placementId は使用しません。

新機能: selectShoppableAds() (iOS のみ)new-selectshoppableads-ios-only への直接リンク

バージョン 5.0 では、Shoppable Ads プレースメントを表示するための RoktSdk.selectShoppableAds() を導入しました。

注記

Flutter の Shoppable Ads は現在 iOS のみでサポートされています。

iOS Podfile 依存関係iOS Podfile 依存関係 への直接リンク

Shoppable Ads を使用する場合、Stripe 支払い拡張機能を ios/Podfile に追加してください:

pod 'RoktPaymentExtension', '~> 2.0'

支払い拡張機能の登録支払い拡張機能の登録 への直接リンク

selectShoppableAds を呼び出す前に、Dart から新しい registerPaymentExtension 呼び出しが必要です。ホストアプリはネイティブ iOS コード (AppDelegate.swift) に支払い拡張機能ファクトリも設定する必要があります:

import RoktPaymentExtension
import rokt_sdk

SwiftRoktSdkPlugin.paymentExtensionFactory = { type, config in
switch type {
case "stripe":
guard let merchantId = config["applePayMerchantId"] else { return nil }
return RoktPaymentExtension(
applePayMerchantId: merchantId,
countryCode: config["countryCode"] ?? "US"
)
default:
return nil
}
}
RoktSdk.registerPaymentExtension(
extensionType: 'stripe',
config: {
'stripeKey': 'YOUR_STRIPE_PUBLISHABLE_KEY',
'applePayMerchantId': 'merchant.com.yourapp.rokt',
},
);

新しい Shoppable Ads イベント新しい Shoppable Ads イベント への直接リンク

以下のイベントが RoktEvents EventChannel を通じて利用可能になりました:

イベント説明
CartItemInstantPurchaseInitiated購入フローが開始されました — ユーザーが「購入」をタップしました
CartItemInstantPurchase購入が正常に完了しました
CartItemInstantPurchaseFailure購入に失敗しました
CartItemDevicePayApple Pay / デバイス支払いがトリガーされました
InstantPurchaseDismissalユーザーが購入オーバーレイを閉じました

プラットフォームの可用性プラットフォームの可用性 への直接リンク

機能iOSAndroid
selectPlacements5.0.05.0.0
selectShoppableAds5.0.0未サポート
registerPaymentExtension5.0.0未サポート
purchaseFinalized5.0.05.0.0

Flutter SDK+ 2.0 (mparticle_flutter_sdk)Flutter SDK+ 2.0 (mparticle_flutter_sdk) への直接リンク

Flutter アプリで mparticle_flutter_sdk1.x から 2.0 にアップグレードする場合、以下の変更が適用されます。

iOS デプロイメントターゲットが 15.0 に引き上げられましたiOS デプロイメントターゲットが 15.0 に引き上げられました への直接リンク

このプラグインは現在 iOS 15.0+ を必要とします。アプリで以下を更新してください:

  • ios/Podfile:

    platform :ios, '15.0'
  • ios/Flutter/AppFrameworkInfo.plistMinimumOSVersion15.0 に設定します。

  • Xcode で、Runner ターゲットの iOS Deployment Target15.0 に引き上げます。

更新後、以下を実行してください:

cd ios
pod deintegrate
pod install
cd ..

CocoaPods依存関係の更新CocoaPods依存関係の更新 への直接リンク

プラグインは現在、mParticle Apple SDK 9に依存しています。サブスペックのサフィックスはもはや有効ではありません:

以前 (1.x)後 (2.0.0)
mParticle-Apple-SDK/mParticle ~> 8.5mParticle-Apple-SDK ~> 9.0

アプリのPodfileがサブスペックを固定している場合(例: pod 'mParticle-Apple-SDK/mParticle', ...)、上記の新しい形式に更新してください。

Roktイベントチャネル — 新しいイベントタイプRoktイベントチャネル — 新しいイベントタイプ への直接リンク

EventChannel('MPRoktEvents')ストリームの利用者は、追加のevent値を受け取ります。既存のイベントタイプの文字列値は変更されていないため、既存のリスナーは引き続き動作します。

新しいイベントタイプとそのペイロードキー:

event追加のキー
CartItemInstantPurchaseInitiatedcartItemId, catalogItemId
CartItemInstantPurchaseFailurecartItemId, catalogItemId, error
InstantPurchaseDismissal
CartItemDevicePaycartItemId, catalogItemId, paymentProvider

新機能: selectShoppableAds (iOSのみ)new-selectshoppableads-ios-only-1 への直接リンク

await MparticleFlutterSdk.getInstance().then((mp) => mp?.rokt.selectShoppableAds(
identifier: 'shoppable-ads-placement',
attributes: {'email': 'user@example.com'},
));
  • iOS: MParticle.sharedInstance().rokt.selectShoppableAds(...)にプロキシします。
  • Android: APIのパリティのためにメソッドは公開されていますが、実際には何もしません(警告をログに記録します)。
  • Web: 未実装 — 呼び出しはMissingPluginExceptionをスローします。

ショッパブル広告の配置に関するイベントは、既存のMPRoktEvents EventChannelで配信されます。

完全なセットアップについては、Flutter SDK+ Shoppable Ads Integrationガイドを参照してください。

支払い拡張 — ネイティブのみの登録支払い拡張 — ネイティブのみの登録 への直接リンク

Rokt支払い拡張機能(RoktPaymentExtension)はDartを介してプロキシされません。統合者は、ホストアプリのネイティブSwiftから直接登録する必要があります(例: ios/Runner/AppDelegate.swift)、MParticle.sharedInstance().start(with:)の後に。mParticle Roktキット設定でstripePublishableKeyを設定してください — キットはそれを自動的にRoktに転送します:

import mParticle_Apple_SDK
import RoktPaymentExtension

if let paymentExt = RoktPaymentExtension(applePayMerchantId: "merchant.com.yourapp.rokt") {
MParticle.sharedInstance().rokt.registerPaymentExtension(paymentExt)
}

Web SDK マイグレーションガイドWeb SDK マイグレーションガイド への直接リンク

このガイドは、Rokt Web SDK の古いバージョン(バージョン 2.5926.0 以前)から最新バージョンへの移行方法を説明します。これは、Rokt Ecommerce と Rokt Ads の両方の実装に関連しており、更新された初期化スクリプトなどの重大な変更点と、移行をスムーズに完了するために Rokt アカウントチームとどのように調整するかについて説明します。

Web SDK の初期化Web SDK の初期化 への直接リンク

新しい SDK で導入された最大の変更点は、Web サイト内での初期化方法です。現在のバージョン以前は、Rokt は、サイト内の各ページの <head> タグから launcher.js または snippet.js スクリプトを呼び出すことで、SDK を初期化またはロードすることを許可していました。

これらのオプションはすべて、単一の初期化スクリプトに置き換えられました。

非推奨の launcher.js スクリプトを削除remove-the-deprecated-launcherjs-script への直接リンク

サイトのコードを検索し、launcher.js スクリプトのインスタンスをすべて削除してください。

それは次のように見えるはずです:

<script type="module">
window.RoktLauncherScriptPromise = new Promise((resolve, reject) => {
const target = document.head || document.body;
const script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://apps.rokt.com/wsdk/integrations/launcher.js";
script.fetchPriority = "high";
script.crossOrigin = "anonymous";
script.async = true;
script.id = "rokt-launcher";

script.addEventListener('load', () => resolve());
script.addEventListener('error', (error) => reject(error));

target.appendChild(script);
});
</script>

非推奨の snippet.js 自動ランチャーを削除remove-the-deprecated-snippetjs-auto-launcher への直接リンク

自動ランチャースニペットを使用していた場合、サイトのコードを検索し、スクリプトのインスタンスをすべて削除してください。

それは次のように見えるはずです:

(function (r, o, k, t, n, e, w, a, _) {
r._ROKT_ = n;
r[n] = r[n] || {
id: t,
h: w,
lc: [],
it: new Date(),
onLoaded: function (c) {
r[n].lc.push(c);
},
};
a = o.createElement("script");
a.type = "text/javascript";
a.async = !0;
a.src = k;
if (e) {
a.integrity = e;
a.crossOrigin = "anonymous";
}
_ = o.getElementsByTagName("script")[0];
_.parentNode.insertBefore(a, _);
})(
window,
document,
"https://apps.rokt.com/wsdk/integrations/snippet.js",
"roktAccountid",
"rokt"
);

新しい SDK 初期化スニペットを挿入新しい SDK 初期化スニペットを挿入 への直接リンク

古い SDK スニペットのインスタンスをすべて削除した後、サイトの各ページの <head> タグに新しい SDK 初期化スニペットを挿入してください。サイトがテンプレートを使用するマルチページアプリケーションである場合、この新しいスニペットが各ページロード時にできるだけ早く実行されるようにテンプレートを更新してください。

維持された初期化手順と構成オプションについては、Initialize the Rokt SDK+ を参照してください。

新しい Rokt Web SDK 初期化スニペット新しい Rokt Web SDK 初期化スニペット への直接リンク
<script type="text/javascript">

// Enter your Rokt API key
const API_KEY = "YOUR_API_KEY";

// Enter your custom subdomain if you are using a first-party domain configuration (optional)
const ROKT_DOMAIN = "https://apps.rokt-api.com";

window.mParticle = {
config: {
// Set the data environment:
// Set isDevelopmentMode to true if you are still testing your integration.
// Set isDevelopmentMode to false if your integration is ready for production data.
isDevelopmentMode: true,
// Identify the current user:
// If you do not have the user's email address, you can pass in a null value
identifyRequest: {
userIdentities: {
// If you're using an un-hashed email address, set it in 'email' (preferred).
email: 'j.smith@example.com',
// If you're using a hashed email address, set it in 'email_sha256' instead of 'email'.
email_sha256: 'sha256 hashed email goes here',
// Customer phone number in E.164 format.
mobile_number: '+13125551515',
// If you're using a hashed mobile number, set it in 'mobile_sha256' instead of 'mobile_number'.
mobile_sha256: 'sha256 hashed mobile goes here',
// Partner's internal customer/account identifier (if the user is logged in).
customerid: 'cust_10482'
}
},
// If the user is identified with their email address, set additional user attributes.
identityCallback: function(result) {
if (result.getUser()) {
result.getUser().setUserAttribute('attribute_key', 'attribute_value');
}
}
}
};

// Load the SDK+
(function(e) { window.mParticle = window.mParticle || {}; window.mParticle.EventType = { Unknown: 0, Navigation: 1, Location: 2, Search: 3, Transaction: 4, UserContent: 5, UserPreference: 6, Social: 7, Other: 8, Media: 9 }; window.mParticle.eCommerce = { Cart: {} }; window.mParticle.Identity = {}; window.mParticle.Rokt = {}; window.mParticle.config = window.mParticle.config || {}; window.mParticle.config.rq = []; window.mParticle.config.snippetVersion = 2.8; window.mParticle.ready = function(e) { window.mParticle.config.rq.push(e); }; ["endSession", "logError", "logBaseEvent", "logEvent", "logForm", "logLink", "logPageView", "setSessionAttribute", "setAppName", "setAppVersion", "setOptOut", "setPosition", "startNewSession", "startTrackingLocation", "stopTrackingLocation"].forEach(function(e) { window.mParticle[e] = function() { var t = Array.prototype.slice.call(arguments); t.unshift(e); window.mParticle.config.rq.push(t); }; }); ["setCurrencyCode", "logCheckout"].forEach(function(e) { window.mParticle.eCommerce[e] = function() { var t = Array.prototype.slice.call(arguments); t.unshift("eCommerce." + e); window.mParticle.config.rq.push(t); }; }); ["identify", "login", "logout", "modify"].forEach(function(e) { window.mParticle.Identity[e] = function() { var t = Array.prototype.slice.call(arguments); t.unshift("Identity." + e); window.mParticle.config.rq.push(t); }; }); ["selectPlacements","hashAttributes","hashSha256","setExtensionData","use","getVersion","terminate","onShoppableAdsReady"].forEach(function(e) { window.mParticle.Rokt[e] = function() { var t = Array.prototype.slice.call(arguments); t.unshift("Rokt." + e); window.mParticle.config.rq.push(t); }; }); var t = window.mParticle.config.isDevelopmentMode ? 1 : 0, n = "?env=" + t, a = window.mParticle.config.dataPlan; if (a) { var o = a.planId, r = a.planVersion; o && (r && (r < 1 || r > 1e3) && (r = null), n += "&plan_id=" + o + (r ? "&plan_version=" + r : "")); } var i = window.mParticle.config.versions, s = []; i && Object.keys(i).forEach(function(e) { s.push(e + "=" + i[e]); }); var c = document.createElement("script"); c.type = "text/javascript"; c.async = !0; window.ROKT_DOMAIN = ROKT_DOMAIN || 'https://apps.rokt-api.com'; mParticle.config.domain = ROKT_DOMAIN.split('//')[1]; c.src = ROKT_DOMAIN + "/js/v2/" + e + "/app.js" + n + "&" + s.join("&"); c.onerror = function() { var u = ["https://apps.","rokt","ecommerce",".com"].join(""); window.ROKT_DOMAIN = u; mParticle.config.domain = u.split("//")[1]; var d = document.createElement("script"); d.type = "text/javascript"; d.async = !0; d.src = u + "/js/v2/" + e + "/app.js" + n + "&" + s.join("&"); var f = document.getElementsByTagName("script")[0]; f.parentNode.insertBefore(d, f); }; var l = document.getElementsByTagName("script")[0]; l.parentNode.insertBefore(c, l); })(API_KEY);
</script>

新しいスニペットには、いくつかの新しい構成オプションが導入されています:

Rokt API キーRokt API キー への直接リンク

以前は、SDK スニペットに Rokt アカウント ID を入力する必要がありました。この要件は、Rokt API キー に置き換えられました。

注記

Rokt アカウント担当者が Rokt API キーを提供します。

ファーストパーティドメインファーストパーティドメイン への直接リンク

新しい Web SDK では、独自のサブドメインを通じて Rokt にリクエストをルーティングすることができます。これは「ファーストパーティドメイン統合」と呼ばれ、コンテンツがブロックされるのを防ぐのに役立ちます。

統合にカスタムサブドメインを使用するには、First Party Domain Integration の指示に従い、初期化スニペット内の ROKT_DOMAIN の値を独自のサブドメインに置き換えてください:

const ROKT_DOMAIN = "https://your-new-subdomain-goes-here";
開発モード開発モード への直接リンク

以前は、SDKスニペットに sandbox: true を設定して統合をテストすることができました。

現在、Rokt SDKには isDevelopmentMode という設定オプションが含まれています。これを true に設定すると、Rokt SDKはデータを「開発」(テスト)データとして収集し転送します。統合のテストが完了したら、isDevelopmentModefalse に変更してください。

初期化時のユーザー識別初期化時のユーザー識別 への直接リンク

初期化中に、SDKはユーザーの生またはハッシュ化されたメールアドレス(提供可能な方)を使用してRoktに identifyRequest を送信し、現在のユーザーを識別します。初期化スクリプトの設定内で identifyRequest に生またはハッシュ化されたメールアドレスを提供できます:

identifyRequest: {
userIdentities: {
// If you're using an un-hashed email address, set it in 'email'.
email: 'j.smith@example.com',
// If you're using a hashed email address, set it in 'email_sha256' instead of `email`.
email_sha256: 'sha256 hashed email goes here'
},
}

ユーザーの識別ユーザーの識別 への直接リンク

SDKが初期化された際にユーザーのメールアドレスを提供できない場合は、ユーザーがメールアドレスを提供したらすぐに、SDKの初期化後に identify メソッドを呼び出してユーザーを識別する必要があります。

ハッシュ化されていないメールアドレスを提供する場合は、以下を使用してください:

const identityRequest = { 
userIdentities: {
email: 'j.smith@example.com'
}
};
mParticle.Identity.identify(identityRequest);

ハッシュ化されたメールアドレスを提供する場合は、以下を使用してください:

const identityRequest = { 
userIdentities: {
email_sha256: 'sha256 hashed email goes here'
}
};
mParticle.Identity.identify(identityRequest);

ユーザー属性の設定ユーザー属性の設定 への直接リンク

現在のユーザーを識別したら、広告配置やログイベントに含まれる説明的なユーザー属性を設定できます。また、配置を挿入する際に直接ユーザー属性を設定することもできます。

ユーザー属性を設定するには、SDKが初期化され、ユーザーを識別した後に以下を実行してください:

// To retrieve the current user, call getCurrentUser. This will only succeed if you have identified the user during SDK initialization or by calling the identify method.
const currentUser = mParticle.Identity.getCurrentUser();

// Once you have successfully set the current user to a const called `currentUser`, you can set user attributes with:
currentUser.setUserAttribute("user-attribute-name", "user-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("city", "Brooklyn");
currentUser.setUserAttribute("state", "NY");
currentUser.setUserAttribute("zip", "123456");
currentUser.setUserAttribute("dob", "yyyymmdd");
currentUser.setUserAttribute("title", "Mr");
currentUser.setUserAttribute("language", "en");
currentUser.setUserAttribute("value", "52.25");
currentUser.setUserAttribute("predictedltv", "136.23");

// To set a list attribute, set the value of the attribute to an array of strings. For example:
currentUser.setUserAttribute("favorite-genres", ["documentary", "comedy", "romance", "drama"]);

// To remove a user attribute, call removeUserAttribute and pass in the attribute name. All user attributes share the same key space.
currentUser.removeUserAttribute("attribute-to-remove");

配置の挿入配置の挿入 への直接リンク

サイトに配置を挿入するために使用されるスクリプトも新しいSDKで置き換えられました。

廃止された selectPlacements メソッド:

以前は、Rokt SDKランチャースクリプトが完了した後に selectPlacements を呼び出して配置を挿入していました:

<script type="module">
await window.RoktLauncherScriptPromise;

const launcher = await window.Rokt.createLauncher({
accountId: "rokt-account-id",
sandbox: true,
});

await launcher.selectPlacements({
attributes: {
email: "",
firstname: "",
lastname: "",
confirmationref: "",
billingzipcode: "",
amount: "",
paymenttype: "",
ccbin: "",
mobile: "",
country: "",
language: "",
currency: "",
billingaddress1: "",
billingaddress2: "",
age: "",
gender: "",
cartItems: JSON.stringify(cartItems),
},
});
</script>

これは mParticle.Rokt.selectPlacements メソッドに置き換えられました:

新しい selectPlacements メソッド:

配置を挿入するには、SDKを初期化した後に新しい mParticle.Rokt.selectPlacements を呼び出してください。前のセクションと同様に、顧客に表示されるコンテンツの関連性を向上させるために属性のリストを提供できます。各配置位置をカバーする維持された例については、配置を表示するを参照してください。

window.mParticle.ready(async function () {
const selection = await window.mParticle.Rokt.selectPlacements({
identifier: "prod.rokt.conf",
attributes: {
// Identity
email: "j.smith@example.com",
firstname: "Jenny",
lastname: "Smith",
mobile_number: "+13125551515",

// Transaction
confirmationref: "ORDER-10482",
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 + paymentServiceProvider for Pay+)
paymenttype: "credit_card",
paymentServiceProvider: "cardpayment",
ccbin: "411112",

// Pass cart items as a real array so the fields remain typed.
cartItems: [
{
cartitemid: "SKU-001",
productsku: "SKU-001",
productname: "Trail Runner v3",
itemprice: 129.95,
quantity: 1
}
]
}
});
});

コンテンツセキュリティポリシー(CSP)の更新コンテンツセキュリティポリシー(CSP)の更新 への直接リンク

サイトでコンテンツセキュリティポリシーを使用している場合、新しいSDKドメインを許可するようにCSPディレクティブを更新する必要があります。新しいSDKは、apps.rokt-api.comに加えて、apps.rokt.comからリソースをロードします。

以下のディレクティブを含むようにCSPを更新してください:

script-src https://apps.rokt.com https://apps.rokt-api.com https://apps.roktecommerce.com https://sourcemaps-wsdk.roktinternal.com;
frame-src https://apps.rokt.com https://apps.rokt-api.com https://apps.roktecommerce.com;

RoktのCSP要件の詳細については、Web Securityを参照してください。

イベントトラッキングの実装イベントトラッキングの実装 への直接リンク

新しいRokt SDKは、イベントおよびユーザー属性を簡単に収集できます。これらの新しいトラッキング方法をサイトに実装する方法については、新しいGetting Started for EcommerceまたはGetting Started for Advertisersガイドを参照してください。

この記事は役に立ちましたか?