adjust-icon

Send subscription information

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 thecurrencyCodeof thepriceLocaleobject.

transactionId (std::string)

Your ID for the transaction.

AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"44da840e-3f70-4bc0-95d2-4b9638e1d7eb" // transactionId
);

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

AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"44da840e-3f70-4bc0-95d2-4b9638e1d7eb" // transactionId
);
subscription.setTransactionDate("txn_20230918T123456Z");

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.

AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"44da840e-3f70-4bc0-95d2-4b9638e1d7eb" // transactionId
);
subscription.setSalesRegion("US");

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.

AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"44da840e-3f70-4bc0-95d2-4b9638e1d7eb" // transactionId
);
subscription.addCallbackParameter("key", "value");
subscription.addCallbackParameter("foo", "bar");

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.

AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"44da840e-3f70-4bc0-95d2-4b9638e1d7eb" // transactionId
);
subscription.addPartnerParameter("key", "value");
subscription.addPartnerParameter("foo", "bar");

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:

  1. How to create create and populate an AdjustAppStoreSubscription2dx or AdjustPlayStoreSubscription2dx instance.
  2. How to use the AdjustAppStoreSubscription2dx and AdjustPlayStoreSubscription2dx classes in your app to send subscription information to Adjust.

To send subscription information to Adjust, follow these steps:

  1. Instantiate and populate an AdjustAppStoreSubscription2dx object with the price, currency, and transactionId. 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"
  2. 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".
  3. At the end of your function, send the information to Adjust by calling trackAppStoreSubscription with your AdjustAppStoreSubscription2dx instance as an argument.
#include "Adjust/Adjust2dx.h"
std::string appToken = "{YOUR_APP_TOKEN}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
Adjust2dx::initSdk(adjustConfig);
AdjustAppStoreSubscription2dx subscription = AdjustAppStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"44da840e-3f70-4bc0-95d2-4b9638e1d7eb" // transactionId
);
subscription.setTransactionDate("txn_20230918T123456Z");
subscription.setSalesRegion("US");
subscription.addCallbackParameter("key", "value");
subscription.addCallbackParameter("foo", "bar");
subscription.addPartnerParameter("key", "value");
subscription.addPartnerParameter("foo", "bar");
Adjust2dx::trackAppStoreSubscription(subscription);

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

AdjustPlayStoreSubscription2dx subscription = AdjustPlayStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"47411084-12dd-41f6-9e4b-2c59e380945e", // sku
"63469457-d777-4698-9957-f07a3d14c7bf", // orderId
"1c37d91e-a3e6-4236-90a7-86c69051fc39", // signature
"4afa8869-0dc6-43ff-be28-d07d454cb357" // 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.

Call the setPurchaseTime method on your subscription object to record the timestamp of the subscription.

purchaseTime (std::string)

The timestamp of the subscription.

AdjustPlayStoreSubscription2dx subscription = AdjustPlayStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"47411084-12dd-41f6-9e4b-2c59e380945e", // sku
"63469457-d777-4698-9957-f07a3d14c7bf", // orderId
"1c37d91e-a3e6-4236-90a7-86c69051fc39", // signature
"4afa8869-0dc6-43ff-be28-d07d454cb357" // purchaseToken
);
subscription.setPurchaseTime("txn_20230918T123456Z");

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.

AdjustPlayStoreSubscription2dx subscription = AdjustPlayStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"47411084-12dd-41f6-9e4b-2c59e380945e", // sku
"63469457-d777-4698-9957-f07a3d14c7bf", // orderId
"1c37d91e-a3e6-4236-90a7-86c69051fc39", // signature
"4afa8869-0dc6-43ff-be28-d07d454cb357" // purchaseToken
);
subscription.addCallbackParameter("key", "value");
subscription.addCallbackParameter("foo", "bar");

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.

AdjustPlayStoreSubscription2dx subscription = AdjustPlayStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"47411084-12dd-41f6-9e4b-2c59e380945e", // sku
"63469457-d777-4698-9957-f07a3d14c7bf", // orderId
"1c37d91e-a3e6-4236-90a7-86c69051fc39", // signature
"4afa8869-0dc6-43ff-be28-d07d454cb357" // purchaseToken
);
subscription.addPartnerParameter("key", "value");
subscription.addPartnerParameter("foo", "bar");

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:

  1. How to create create and populate an AdjustAppStoreSubscription2dx or AdjustPlayStoreSubscription2dx instance.
  2. How to use the AdjustAppStoreSubscription2dx and AdjustPlayStoreSubscription2dx classes in your app to send subscription information to Adjust.

To send subscription information to Adjust, follow these steps:

  1. Instantiate and populate an AdjustPlayStoreSubscription2dx object with the price, 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".
  2. 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".
  3. At the end of your function, send the information to Adjust by calling trackPlayStoreSubscription with your AdjustAppStoreSubscription2dx instance as an argument.
#include "Adjust/Adjust2dx.h"
std::string appToken = "{YOUR_APP_TOKEN}";
std::string environment = AdjustEnvironmentSandbox2dx;
AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment);
Adjust2dx::initSdk(adjustConfig);
AdjustPlayStoreSubscription2dx subscription = AdjustPlayStoreSubscription2dx(
"1.00", // price
"EUR", // currency
"47411084-12dd-41f6-9e4b-2c59e380945e", // sku
"63469457-d777-4698-9957-f07a3d14c7bf", // orderId
"1c37d91e-a3e6-4236-90a7-86c69051fc39", // signature
"4afa8869-0dc6-43ff-be28-d07d454cb357" // purchaseToken
);
subscription.setPurchaseTime("txn_20230918T123456Z");
subscription.addCallbackParameter("key", "value");
subscription.addCallbackParameter("foo", "bar");
subscription.addPartnerParameter("key", "value");
subscription.addPartnerParameter("foo", "bar");
Adjust2dx::trackPlayStoreSubscription(subscription);