You can record App Store and Play Store subscriptions and verify their validity with the Adjust SDK. After the user purchases a subscription, create an AdjustAppStoreSubscription
or AdjustPlayStoreSubscription
instance containing the details.
1. Instantiate a subscription object
To get started, you need to create a subscription object containing details of the subscription purchase.
constructor(price: string, currency: string, transactionId: string, receipt: string)
Create an AdjustAppStoreSubscription
object with the following properties
Parameter | Data type | Description |
---|---|---|
price | string | The price of the subscription |
currency | string | The currency of the subscription. Formatted as the currencyCode of the priceLocale object |
transactionId | string | Your ID for the transaction |
receipt | string | The receipt information |
var subscription = new AdjustAppStoreSubscription( price, currency, transactionId, receipt,);Adjust.trackAppStoreSubscription(subscription);
constructor(price: string, currency: string, sku: string, orderId: string, signature: string, purchaseToken: string)
Create an AdjustPlayStoreSubscription
object with the following properties
Parameter | Data type | Description |
---|---|---|
price | string | The price of the subscription |
currency | string | The currency of the subscription |
sku | string | The ID of the product |
orderId | string | Your ID for the transaction |
signature | string | The signature of the purchase data |
purchaseToken | string | The unique token of the transaction. See Google’s documentation for more information |
var subscription = new AdjustPlayStoreSubscription( price, currency, sku, orderId, signature, purchaseToken,);
Record the purchase date
You can record the date on which the user purchased a subscription. The SDK returns this data for you to report on.
public setTransactionDate(transactionDate: string): void
Call the setTransactionDate
method method on your subscription object to record the timestamp of the subscription.
var subscription = new AdjustAppStoreSubscription( price, currency, transactionId, receipt,);
subscription.setTransactionDate(transactionDate);Adjust.trackAppStoreSubscription(subscription);
public setPurchaseTime(purchaseTime: string): void
Call the setPurchaseTime
method on your subscription object to record the timestamp of the subscription.
var subscription = new AdjustPlayStoreSubscription( price, currency, sku, orderId, signature, purchaseToken,);subscription.setPurchaseTime(purchaseTime);
Record the purchase region (iOS only)
public setSalesRegion(salesRegion: string): void
You can record the region in which the user purchased a subscription. To do this, call the setSalesRegion
method on your subscription object and pass the country code as a string
. This needs to be formatted as the countryCode
of the priceLocale
object.
var subscription = new AdjustAppStoreSubscription( price, currency, transactionId, receipt,);
subscription.setSalesRegion(salesRegion);Adjust.trackAppStoreSubscription(subscription);
Add callback parameters
You can add callback parameters to your subscription object. The SDK appends these parameters to your callback URL. To add callback parameters, call the addCallbackParameter
method on your subscription object. You can add multiple callback parameters by calling this method multiple times.
public addCallbackParameter(key: string, value: string): void
var subscription = new AdjustAppStoreSubscription( price, currency, transactionId, receipt,);subscription.setTransactionDate(transactionDate);subscription.setSalesRegion(salesRegion);
subscription.addCallbackParameter("key1", "value1");subscription.addCallbackParameter("key2", "value2");
Adjust.trackAppStoreSubscription(subscription);
public addCallbackParameter(key: string, value: string): void
var subscription = new AdjustPlayStoreSubscription( price, currency, sku, orderId, signature, purchaseToken,);
subscription.addCallbackParameter("key1", "value1");subscription.addCallbackParameter("key2", "value2");
Add partner parameters
You can add partner parameters to your subscription object. The SDK sends these to Adjust’s servers when the user purchases a subscription. Adjust’s servers forward the information on to your network partner. To add partner parameters, call the addPartnerParameter
method on your subscription object. You can add multiple partner parameters by calling this method multiple times.
public addPartnerParameter(key: string, value: string): void
var subscription = new AdjustAppStoreSubscription( price, currency, transactionId, receipt,);subscription.setTransactionDate(transactionDate);subscription.setSalesRegion(salesRegion);
subscription.addPartnerParameter("key1", "value1");subscription.addPartnerParameter("key2", "value2");
Adjust.trackAppStoreSubscription(subscription);
public addPartnerParameter(key: string, value: string): void
var subscription = new AdjustPlayStoreSubscription( price, currency, sku, orderId, signature, purchaseToken,);
subscription.addPartnerParameter("key1", "value1");subscription.addPartnerParameter("key2", "value2");
2. Record subscription information
Once you have set up your subscription object, you can record it using the Adjust SDK.
trackAppStoreSubscription: (subscription: AdjustAppStoreSubscription) => void
Pass your subscription object to the trackAppStoreSubscription
method method to record the user’s subscription purchase.
var subscription = new AdjustAppStoreSubscription( price, currency, transactionId, receipt,);subscription.setTransactionDate(transactionDate);subscription.setSalesRegion(salesRegion);
Adjust.trackAppStoreSubscription(subscription);
trackPlayStoreSubscription: (subscription: AdjustPlayStoreSubscription) => void
Pass your subscription object to the trackPlayStoreSubscription
method method to record the user’s subscription purchase.
var subscription = new AdjustPlayStoreSubscription( price, currency, sku, orderId, signature, purchaseToken,);subscription.setPurchaseTime(purchaseTime);
Adjust.trackPlayStoreSubscription(subscription);