Revenue Outcomes
Learn when and how to log revenue outcomes in ContextSDK to optimize monetization and improve model accuracy.
This API is only available in iOS at the moment. Please reach out to our team if you need this API in Android.
What is a revenue outcome?
A revenue outcome represents the result of a monetization event in your app, such as an in-app purchase or an ad impression.
Why is it important?
Understanding how and when users contribute to revenue allows ContextSDK to make informed predictions about the best moments to display monetization opportunities. Logging revenue outcomes helps ContextSDK optimize your ML models, ensuring that monetization decisions align with real-world user behavior, so we can optimize your app for revenue generation.
When should I log revenue outcomes?
Log a revenue outcome whenever the user generates revenue. This includes in-app purchases, ad clicks, ad impressions, tips, or other sources of revenue.
Use revenue outcomes only for events that directly lead to revenue. For non-revenue actions that are positive, like permission prompts or rating requests, use standalone positive outcomes instead of revenue outcomes.
If the user dismisses the offer or doesn’t convert, log a standalone negative outcome, not a revenue outcome.
How to log revenue outcomes
Here's a few examples of how to log revenue outcomes for different scenarios.
In-app purchases
If you're using StoreKit 2, log a purchase like this:
If you're using RevenueCat, see Logging Revenue with RevenueCat
If you’re using a different in-app purchase framework, retrieve the equivalent StoreKit product object and pass it to logRevenueOutcome(from:)
.
There's no need to call context.log(.positive)
after logging a revenue outcome from a Product
, as the positive outcome is already logged internally. Alternatively, you can customize the outcome to be logged directly, via logRevenueOutcome(from:outcome:)
.
Ad clicks and impressions
For an ad click, log the revenue outcome as follows:
Or for an ad impression:
The revenue values in these examples are placeholders. Use the actual revenue values from your ad network's SDK, preferring the most precise values available. If exact values aren't provided, an estimate is acceptable, however, greater precision improves accuracy.
Some ad networks may provide callbacks that contain live revenue data. Use this data to log revenue outcomes in real-time, ensuring that the revenue data is as accurate as possible.
Best practices
Avoid duplicate logging: Use
logRevenueOutcomeIfNotLoggedYet(from:)
for events where duplicate logging may occur.
Last updated
Was this helpful?