Android Native
Tracking Revenue
The Noctua SDK supports purchase and revenue tracking for monetization analytics.
Track Purchase
import com.noctuagames.sdk.Noctua
import com.noctuagames.sdk.model.PurchaseData
val purchaseData = PurchaseData(
productId = "com.example.coin_pack",
price = 4.99,
currency = "USD",
transactionId = "txn_123456789"
)
Noctua.trackPurchase(purchaseData)
Note
Always pass the correct currency code (ISO 4217 format, e.g., "USD"). Ensure transactionId is unique to avoid duplication.
Track Ad Revenue
You can track ad revenue events using the Noctua SDK to measure monetization performance across ad networks.
Example
import com.noctuagames.sdk.Noctua
val revenueData = mapOf(
"ad_network" to "AdMob",
"placement" to "rewarded_video",
"revenue" to 0.015,
"currency" to "USD"
)
Noctua.trackEvent("ad_revenue", revenueData)
Parameters
- source: The source of the ad revenue. Use
admob_sdkfor AdMob orapplovin_max_sdkfor AppLovin MAX. - revenue: The revenue of the ad.
- currency: The currency of the ad revenue.
- parameters: A dictionary of parameters to track with the event.
Data Sources
Applovin
override fun onAdRevenuePaid(ad: MaxAd)
{
val revenue = ad.revenue // In USD
// Miscellaneous data
val platform = "AppLovin"
val countryCode = AppLovinSdk.getInstance( context ).configuration.countryCode // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD"
val placement = ad.placement // The placement this ad's postbacks are tied to
val networkPlacement = ad.networkPlacement // The placement ID from the network that showed the ad
// Example how to track ad revenue
Noctua.trackAdRevenue(
"applovin_max_sdk",
revenue,
"USD",
mapOf(
"platform" to platform,
"networkPlacement" to networkPlacement
)
)
// Example how to track custom event with revenue
Noctua.trackCustomEventWithRevenue(
"ad_impression",
revenue,
currency,
mapOf(
"platform" to platform,
"networkSource" to networkSource
)
)
}
Admob
private fun setOnPaidEventListener(ad: RewardedAd) {
ad.onPaidEventListener = OnPaidEventListener { adValue ->
// Extract the impression-level ad revenue data.
val valueMicros = adValue.valueMicros
val revenue = valueMicros / 1_000_000.0
val currencyCode = adValue.currencyCode
// Get the ad unit ID.
val adUnitId = ad.adUnitId
// Extract ad response information.
val loadedAdapterResponseInfo = ad.responseInfo.loadedAdapterResponseInfo
val adSourceName = loadedAdapterResponseInfo?.adSourceName
// Example how to track ad revenue
Noctua.trackAdRevenue(
"admob_sdk",
revenue,
currencyCode,
mapOf(
"adSourceName" to adSourceName
)
)
// Example how to track custom event with revenue
Noctua.trackCustomEventWithRevenue(
"ad_impression",
revenue,
currencyCode,
mapOf(
"adSourceName" to adSourceName
)
)
}
}
Sources
- AppLovin: Impression-Level User Revenue API
- AdMob: Implement a Paid Event Handler