Implement A/B tests in Observer mode

Implement A/B tests in Adapty's Observer mode by associating transactions to corresponding paywalls in your mobile app code

If you already have your own purchase infrastructure and aren't prepared to switch to Adapty's system, you can explore the Adapty Observer mode.

Enable A/B tests in Observer mode

In Observer mode, Adapty SDK cannot determine the source of purchases as you make them in your own infrastructure. Therefore, if you intend to use A/B tests in Observer mode, you need to associate the transaction coming from your app store with the corresponding paywall in your mobile app code.

Preliminary configuration

  1. Set up initial integration of Adapty with the Google Play and with the App Store.
  2. Install and configure Adapty SDK. Make sure to set the observerMode parameter to true. Refer to our framework-specific instructions for iOS, for Android, for Flutter, for React Native, and for Unity.
  3. Create products in the Adapty Dashboard.
  4. Configure paywalls and assign products to them using the remote config in the Adapty Dashboard.
  5. Set up A/B tests and allocate paywalls to them in the Adapty Dashboard.
  6. Create placements and assign A/B tests to them in the Adapty Dashboard.
  7. Display paywalls designed with remote config in your mobile app.
  8. Implement making purchases on the paywall buy-button click.

Mapping used paywalls to purchase transactions

After the preliminary configuration is done, you need to map the transaction generated by Apple with the corresponding paywall in your mobile app code using the variationId parameter as shown in the example below. Only if you accurately associate them, you will be able to see the correct metrics in the Adapty Dashboard.

let variationId = paywall.variationId

// There are two overloads: for StoreKit 1 and StoreKit 2
Adapty.setVariationId(variationId, forPurchasedTransaction: transaction) { error in
    if error == nil {
        // successful binding
    }    
}
Adapty.setVariationId(transactionId, variationId) { error ->
    if (error == null) {
        // success
    }
}
Adapty.setVariationId(transactionId, variationId, error -> {
    if (error == null) {
        // success
    }
});
final transactionId = transaction.transactionIdentifier
final variationId = paywall.variationId

try {
  await Adapty().setVariationId('transaction_id', variationId);
} on AdaptyError catch (adaptyError) {
  // handle the error
} catch (e) {
}
const variationId = paywall.variationId;

try {
	await adapty.setVariationId('transaction_id', variationId);
} catch (error) {
	// handle the `AdaptyError`
}
Adapty.SetVariationForTransaction("<variationId>", "<transactionId>", (error) => { 
    if(error != null) {
        // handle the error
        return;
    }

    // successful binding
});

Request parameters:

ParameterPresenceDescription
variationIdrequiredThe string identifier of the variation. You can get it using variationId property of the AdaptyPaywall object.
transactionrequiredFor iOS, StoreKit1: an SKPaymentTransaction object.
For iOS, StoreKit 2: Transaction object.
For Android: String identifier (purchase.getOrderId()) of the purchase, where the purchase is an instance of the billing library Purchase class.

For accurate analytics, ensure the transaction is associated with the paywall within 3 hours of its creation.