LogoLogo
SDK ReferenceChangelogBlogStatusGet HelpGo To Dashboard
  • Introduction
  • Basics
    • How ContextDecision Works
    • How ContextPush Works
    • Getting Started
  • Context Decision
    • Logging Conversions
    • Revenue Outcomes
      • Logging Revenue with RevenueCat
    • Adding Entry Points
    • Release Checklist
    • Advanced
      • Custom Signals
      • Alternative Outcomes
      • Custom Outcome Metadata
      • Listening for Good Moments
      • Model Distribution Methods
      • Custom A/B Test Segmentation
      • Analytics & Reporting
  • Context Push
    • Integrating ContextPush
    • Push Notification Providers
      • OneSignal
      • Customer.io
      • Simple Web Request
    • Release Checklist
    • Analytics & Reporting
  • Discover By Use Cases
    • Multivariate Monetization
    • Inline Banners
  • Other Information
    • Glossary
    • Updating Your SDK
    • Minimum SDK Requirements
    • FAQ
    • Get Help
    • Changelog
  • Advanced
    • Custom Configuration
    • Capturing Context In Key Moments
Powered by GitBook
On this page
  • What is a revenue outcome?
  • Why is it important?
  • When should I log revenue outcomes?
  • How to log revenue outcomes
  • In-app purchases
  • Ad clicks and impressions
  • Best practices

Was this helpful?

  1. Context Decision

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:

// `product` is the StoreKit 2 product that was purchased.
context.logRevenueOutcome(from: product)
let products = try await Product.products(for: productIdentifier)
if let product = products.first {
    context.logRevenueOutcome(from: products.first!)
} else {
    // Handle this scenario, even though it shouldn't be possible
}

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:

let event = RevenueEvent(source: .adClick, revenue: 0.09, currency: .usd)
context.logRevenueOutcome(from: event, outcome: .positiveAdTapped)

Or for an ad impression:

let event = RevenueEvent(source: .adImpression, revenue: 0.00175, currency: .usd)
context.logRevenueOutcome(from: event, outcome: .negativeNotInteracted)

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.

PreviousLogging ConversionsNextLogging Revenue with RevenueCat

Last updated 24 days ago

Was this helpful?

If your app still uses Store Kit 1, fetch the and access its . With this identifier, you can fetch the StoreKit 2 product using :

SKProduct
productIdentifier
products(for:)