> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.qonversion.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Context-specific experiments

You can analyze the impact of context-specific revenue experiments exclusively on the users who made purchases inside the specific context. Qonversion enables this with advanced purchase configurations. For instance, you want to analyze the performance of your onboarding process for your onboarding right away, without including revenue from other screens in the experiment.

<br />

```swift Swift theme={null}
let purchaseOptions = Qonversion.PurchaseOptions(contextKeys: ["mainOnboarding"])

Qonversion.shared().purchaseProduct(product, options: purchaseOptions) { (entitlements, error, isCancelled) in  
  // handle result here
}
```

```objectivec Objective-C theme={null}
QONPurchaseOptions *purchaseOptions = [[QONPurchaseOptions alloc] initWithContextKeys:@[@"mainOnboarding"]];
[[Qonversion sharedInstance] purchaseProduct:product
                                     options:purchaseOptions
                                  completion:^(NSDictionary<NSString *,QONEntitlement *> * _Nonnull entitlements,
                                               NSError * _Nullable error,
                                               BOOL cancelled) {
  // handle result here
}];
```

```java Java theme={null}
final QPurchaseOptions purchaseOptions = new QPurchaseOptions.Builder()
        .setContextKeys(Arrays.asList("mainOnboarding"))
        .build();
Qonversion.getSharedInstance().purchase(
    this,
    product,
    purchaseOftions,
    new QonversionEntitlementsCallback() {
        @Override
        public void onSuccess(@NotNull Map<String, QEntitlement> entitlements) {
            // handle result here
        }

        @Override
        public void onError(@NotNull QonversionError error) {
            // Handle error here
        }
		}
);
```

```kotlin Kotlin theme={null}
val purchaseOptions = QPurchaseOptions.Builder()
    .setContextKeys(listOf("mainOnboarding"))
    .build()
Qonversion.shared.purchase(
    this,
    product,
    purchaseOptions,
    callback = object : QonversionEntitlementsCallback {
        override fun onSuccess(entitlements: Map<String, QEntitlement>) {
            // handle result here
        }

        override fun onError(error: QonversionError) {
            // handle error here
        }
    }
)
```

```javascript Flutter theme={null}
var purchaseOptions = QPurchaseOptionsBuilder()
    .setContextKeys(['mainOnboarding'])
    .build();
var entitlements = await Qonversion.getSharedInstance().purchaseProduct(
    product,
    purchaseOptions: purchaseOptions
);
```

```javascript React Native theme={null}
const purchaseOptions = new PurchaseOptionsBuilder()
  .setContextKeys(['mainOnboarding'])
  .build();
const entitlements = await Qonversion.getSharedInstance().purchaseProduct(product, purchaseOptions);
```

```csharp Unity theme={null}
var purchaseOptions = new PurchaseOptionsBuilder()
    .SetContextKeys(new List<string> {"mainOnboarding"})
    .Build();
Qonversion.GetSharedInstance().PurchaseProduct(product, purchaseOptions, (entitlements, error, isCancelled) =>
{
    // handle result here
});
```

```typescript Cordova theme={null}
const purchaseOptions = new Qonversion.PurchaseOptionsBuilder()
  .setContextKeys(['mainOnboarding'])
  .build();
const entitlements = await Qonversion.getSharedInstance().purchaseProduct(product, purchaseOptions);
```

```typescript Capacitor theme={null}
const purchaseOptions = new PurchaseOptionsBuilder()
  .setContextKeys(['mainOnboarding'])
  .build();
const entitlements = await Qonversion.getSharedInstance().purchaseProduct(product, purchaseOptions);
```
