You can record App Store and Play Store subscriptions and verify their validity with the Adjust SDK.
How it works
After the user purchases a subscription, create an AdjustAppStoreSubscription2dx
or AdjustPlayStoreSubscription2dx
instance. These classes contain properties representing subscription details that allow Adjust to measure the subscription event.
App Store subscriptions
The AdjustAppStoreSubscription2dx
class represents App Store subscription information. You can create multiple instances of this class to send subscription information to Adjust.
To get started, you need to instantiate a subscription object containing details of the subscription purchase.
Instantiate an App Store subscription object
Instantiate an AdjustAppStoreSubscription2dx
object with the following arguments:
price
(std::string
)The price of the subscription
currency
(std::string
)The currency of the subscription. Formatted as the
currencyCode
of thepriceLocale
object.transactionId
(std::string
)Your ID for the transaction.
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.
Call the setTransactionDate
method on your subscription object to record the timestamp of the subscription.
transactionDate
(std::string
)The timestamp of the subscription
Record the purchase region
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 Storefront
object.
salesRegion
(std::string
)The country code for the 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.
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.
App Store subscription tutorial
Once you have set up your subscription object, you can record it using the Adjust SDK.
This tutorial demonstrates how to use the AdjustAppStoreSubscription2dx
and AdjustPlayStoreSubscription2dx
classes to send subscription information to Adjust. You will learn:
- How to create create and populate an
AdjustAppStoreSubscription2dx
orAdjustPlayStoreSubscription2dx
instance. - How to use the
AdjustAppStoreSubscription2dx
andAdjustPlayStoreSubscription2dx
classes in your app to send subscription information to Adjust.
To send subscription information to Adjust, follow these steps:
- Instantiate and populate an
AdjustAppStoreSubscription2dx
object with theprice
,currency
, andtransactionId
. In the example below, the following values are used:- The
price
is "1.00". - The
currency
is "EUR". - The
transactionId
is "44da840e-3f70-4bc0-95d2-4b9638e1d7eb"
- The
- In the example below, the following properties are set:
- The transaction date is set to "txn_20230918T123456Z"
- The sales region is set to "US".
- The callback parameters are set to "key", "value" and "foo", "bar".
- The partner parameters are set to "key", "value" and "foo", "bar".
- At the end of your function, send the information to Adjust by calling
trackAppStoreSubscription
with yourAdjustAppStoreSubscription2dx
instance as an argument.
Play Store subscriptions
The AdjustPlayStoreSubscription2dx
class represents App Store subscription information. You can create multiple instances of this class to send subscription information to Adjust.
To get started, you need to instantiate a subscription object containing details of the subscription purchase.
Instantiate a Play Store subscription object
Instantiate an AdjustPlayStoreSubscription2dx
object with the following arguments:
price
(std::string
)The price of the subscription
currency
(std::string
)The currency of the subscription
sku
(std::string
)The ID of the product
orderId
(std::string
)Your ID for the transaction
signature
(std::string
)The signature of the purchase data
purchaseToken
(std::string
)The unique token of the transaction. SeeGoogle's documentationfor more information
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.
Call the setPurchaseTime
method on your subscription object to record the timestamp of the subscription.
purchaseTime
(std::string
)The timestamp of the 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.
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.
Play Store subscription tutorial
Once you have set up your subscription object, you can record it using the Adjust SDK.
This tutorial demonstrates how to use the AdjustAppStoreSubscription2dx
and AdjustPlayStoreSubscription2dx
classes to send subscription information to Adjust. You will learn:
- How to create create and populate an
AdjustAppStoreSubscription2dx
orAdjustPlayStoreSubscription2dx
instance. - How to use the
AdjustAppStoreSubscription2dx
andAdjustPlayStoreSubscription2dx
classes in your app to send subscription information to Adjust.
To send subscription information to Adjust, follow these steps:
- Instantiate and populate an
AdjustPlayStoreSubscription2dx
object with theprice
,currency
,sku
,orderId
,signature
,purchaseToken
. In the example below, the following values are used:- The
price
is "1.00". - The
currency
is "EUR". - The
sku
is "47411084-12dd-41f6-9e4b-2c59e380945e". - The
orderId
is "63469457-d777-4698-9957-f07a3d14c7bf". - The
signature
is "1c37d91e-a3e6-4236-90a7-86c69051fc39". - The
purchaseToken
is "4afa8869-0dc6-43ff-be28-d07d454cb357".
- The
- In the example below, the following properties are set:
- The purchase time is set to "txn_20230918T123456Z"
- The callback parameters are set to "key", "value" and "foo", "bar".
- The partner parameters are set to "key", "value" and "foo", "bar".
- At the end of your function, send the information to Adjust by calling
trackPlayStoreSubscription
with yourAdjustAppStoreSubscription2dx
instance as an argument.