App StoreおよびPlay Storeのサブスクリプションを計測し、それぞれの有効性をAdjust SDKで確認できます。ユーザーがサブスクリプションの購入を完了したら、その詳細を含むAdjustAppStoreSubscription2dx
またはAdjustPlayStoreSubscription2dx
を作成してください。
1. サブスクリプションオブジェクトをインスタンス化する
開始するには、サブスクリプション購入の詳細を含むサブスクリプションオブジェクトを作成する必要があります。
public: AdjustAppStoreSubscription2dx(std::string price, std::string currency, std::string transactionId, std::string receipt)
以下のプロパティを含むAdjustAppStoreSubscription2dx
オブジェクトを作成します:
パラメーター | データタイプ | 説明 |
---|---|---|
price | 文字列 | サブスクリプションの価格 |
currency | 文字列 | サブスクリプションの通貨。priceLocale オブジェクトのcurrencyCode としてフォーマットされる |
transactionId | 文字列 | トランザクションID |
receipt | 文字列 | レシート情報 |
AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx( price, currency, transactionId, receipt);
購入データを記録する
ユーザーがサブスクリプションを購入した日を記録することができます。SDKはこのデータを返して、レポートします。
void setTransactionDate(std::string transactionDate);
サブスクリプションオブジェクトでsetTransactionDate
メソッドを呼び出し、サブスクリプションのタイムスタンプを記録します。
AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx( price, currency, transactionId, receipt);subscription.setTransactionDate(transactionDate);
購入地域を記録する(iOSのみ)
void setSalesRegion(std::string salesRegion);
ユーザーがサブスクリプションを購入した地域を記録することができます。これを行うには、subscriptionオブジェクトのsetSalesRegion
メソッドを呼び、国コードを 文字列 としてパスします。これは、Storefront
オブジェクトのcountryCode
としてフォーマットされる必要があります。
AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx( price, currency, transactionId, receipt);subscription.setSalesRegion(salesRegion);
コールバックパラメーターを追加する
コールバックパラメーターをサブスクリプションオブジェクトに追加することができます。Adjustは、これらのパラメーターをコールバックURLに追加します。コールバックパラメーターを追加するには、サブスクリプションオブジェクトのaddCallbackParameter
メソッドを呼び出してください。このメソッドを複数回呼び出すことで、複数のコールバックパラメーターを追加できます。
void addCallbackParameter(std::string key, std::string value);
AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx( price, currency, transactionId, receipt);subscription.addCallbackParameter("key1", "value1");subscription.addCallbackParameter("key2", "value2");
パートナーパラメーターの追加
パートナーパラメーターをサブスクリプションオブジェクトに追加することができます。SDKは、ユーザーがサブスクリプションを購入した時に、Adjustサーバーへこれらを送信します。Adjustサーバーは、その情報をネットワークパートナーに転送します。パラメーターパラメーターを追加するには、サブスクリプションオブジェクトのaddPartnerParameter
メソッドを呼び出してください。このメソッドを複数回呼び出すことで、複数のコールバックパラメーターを追加できます。
void addPartnerParameter(std::string key, std::string value);
AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx( price, currency, transactionId, receipt);subscription.addPartnerParameter("key1", "value1");subscription.addPartnerParameter("key2", "value2");
2. サブスクリプション情報を記録する
サブスクリプションオブジェクトを設定したら、Adjust SDKを使用して記録することが可能です。
static void trackAppStoreSubscription(AdjustAppStoreSubscription2dx subscription);
完了したオブジェクトを trackAppStoreSubscription
メソッドにパスして、ユーザーのサブスクリプション購入を記録します。
AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx( price, currency, transactionId, receipt);subscription.setTransactionDate(transactionDate);subscription.setSalesRegion(salesRegion);subscription.addCallbackParameter("key1", "value1");subscription.addCallbackParameter("key2", "value2");subscription.addPartnerParameter("key1", "value1");subscription.addPartnerParameter("key2", "value2");Adjust2dx::trackAppStoreSubscription(subscription);