---
id: "ad-monetization/manual-integration"
title: "Manual Integration"
description: "Track ad events from any mediation platform that provides impression-level revenue data (ILRD) by calling AdTracker methods from your SDK callbacks. Ad impressions, clicks, and revenue appear alongside your subscription data in RevenueCat Charts."
permalink: "/docs/ad-monetization/manual-integration"
slug: "manual-integration"
version: "current"
original_source: "docs/ad-monetization/manual-integration.mdx"
---

> **AI agents:** This is the Markdown version of a RevenueCat documentation page. For the complete documentation index, see [llms.txt](https://www.revenuecat.com/docs/llms.txt).

Track ad events from any mediation platform that provides impression-level revenue data (ILRD) by calling `AdTracker` methods from your SDK callbacks. Ad impressions, clicks, and revenue appear alongside your subscription data in RevenueCat Charts.

:::warning[Using Google AdMob? Use the adapter]
If your app uses Google Mobile Ads on iOS (Swift), Android (Kotlin), Flutter, React Native, or Unity, use the [AdMob adapter](https://www.revenuecat.com/docs/ad-monetization/admob) instead of this page. It tracks every ad event from AdMob's callbacks with no tracking code of your own. Use manual integration with AdMob only from Java-only Android, Objective-C, or Kotlin Multiplatform, which have no adapter.
:::

## Overview

Manual integration gives you full control over ad event tracking and works with any mediation platform that supports ILRD, including:

- AppLovin MAX
- Unity LevelPlay (formerly ironSource), including Unity Ads served through it
- Any custom mediation setup

Hook into your mediation platform's callbacks and call the appropriate `AdTracker` methods.

## How it works

1. **Your mediation platform fires a callback** (e.g., ad loaded, ad displayed, revenue generated)
2. **You call the corresponding AdTracker method** with the event data
3. **RevenueCat records the event** and makes it available in Charts

## Prerequisites

- **SDK Version**:
  - Android: `purchases-android` 10.19.0+
  - iOS: `purchases-ios` 5.89.0+
  - Flutter: `purchases_flutter` 10.10.1+
  - Unity: `purchases-unity` 9.9.0+
  - React Native: `react-native-purchases` 10.8.1+
- **Rewarded ad prompt events** (`trackRewardedAdPromptShown` and `trackRewardedAdPromptAccepted`) require `purchases-ios` 5.92.0+, `purchases-android` 10.24.0+, `purchases_flutter` 10.15.0+, `react-native-purchases` 10.12.0+, `purchases-unity` 9.13.0+, or `purchases-kmp` 3.12.0+.
- **iOS Availability**: Ad tracking requires iOS 15.0+ / tvOS 15.0+ / macOS 12.0+ / watchOS 8.0+. On older OS versions, calls are silently ignored and a warning is logged.
- **ILRD Support**: Your mediation platform must provide impression-level revenue data. If using Google AdMob, you must enable **"Impression-level ad revenue"** in your [AdMob dashboard](https://admob.google.com/) under **Settings**.

## Android integration

:::tip[Using Google AdMob?]
The [AdMob adapter](https://www.revenuecat.com/docs/ad-monetization/admob) for Android tracks these events for you from Kotlin. Use the manual API below for other mediation platforms, or from Java, where the adapter helpers aren't available.
:::

### 1. Access the AdTracker

```kotlin
import com.revenuecat.purchases.Purchases

val adTracker = Purchases.sharedInstance.adTracker
```

### 2. Import event types

```kotlin
import com.revenuecat.purchases.ads.events.types.*
```

### 3. Track events from mediation callbacks

Wire every lifecycle callback, not only revenue. The two examples below show the pattern; the remaining methods take the same parameters:

#### Track ad loaded

Call when an ad successfully loads:

```kotlin
fun onAdLoaded(ad: YourAdType) {
    adTracker.trackAdLoaded(
        AdLoadedData(
            networkName = ad.networkName,            // e.g., "Google Ads"
            mediatorName = AdMediatorName.APP_LOVIN, // or custom: AdMediatorName.fromString("YourMediator")
            adFormat = AdFormat.REWARDED,            // BANNER, INTERSTITIAL, etc.
            placement = "home_screen",               // Your custom placement ID
            adUnitId = ad.adUnitId,                  // Ad unit identifier
            impressionId = ad.impressionId           // Unique impression ID
        )
    )
}
```

#### Track ad revenue

Call when your mediation platform reports revenue for an impression:

```kotlin
fun onAdRevenue(ad: YourAdType, revenue: Double, currency: String) {
    adTracker.trackAdRevenue(
        AdRevenueData(
            networkName = ad.networkName,
            mediatorName = AdMediatorName.APP_LOVIN,
            adFormat = AdFormat.REWARDED,
            placement = "home_screen",
            adUnitId = ad.adUnitId,
            impressionId = ad.impressionId,
            revenueMicros = (revenue * 1_000_000).toLong(), // Convert to micros
            currency = currency,                             // e.g., "USD"
            precision = AdRevenuePrecision.EXACT             // Or ESTIMATED, PUBLISHER_DEFINED
        )
    )
}
```

#### Wire the remaining callbacks

These follow the same pattern as `trackAdLoaded`. Displayed, opened, and failed to load are part of a complete integration: without them, Charts show revenue but no impressions, clicks, or fill rate. For rewarded ads, also track the earned reward and the prompt that offered the ad, so the rewarded funnel in Charts is complete.

- **`trackAdDisplayed(AdDisplayedData)`** - Call when ad impression is recorded (ad shown on screen)
- **`trackAdOpened(AdOpenedData)`** - Call when user clicks/taps the ad
- **`trackAdFailedToLoad(AdFailedToLoadData)`** - Call when ad fails to load (doesn't require `networkName` or `impressionId`)
- **`trackAdRewardEarnedUnverified(AdRewardEarnedUnverifiedData)`** - Call when the ad SDK reports an earned reward; see [earned-reward tracking](#track-unverified-earned-rewards) for examples
- **`trackRewardedAdPromptShown` / `trackRewardedAdPromptAccepted`** - Rewarded ads only; see [Track rewarded ad prompts](#track-rewarded-ad-prompts)

See the [Event data reference](#event-data-reference) section below for complete parameter details.

## iOS integration

:::tip[Using Google AdMob?]
The [AdMob adapter](https://www.revenuecat.com/docs/ad-monetization/admob) for iOS tracks these events for you from Swift. Use the manual API below for other mediation platforms, or from Objective-C, where the adapter isn't available.
:::

### 1. Access the AdTracker

```swift
import RevenueCat

let adTracker = Purchases.shared.adTracker
```

:::info[iOS availability]
Ad tracking requires iOS 15.0+, tvOS 15.0+, macOS 12.0+, and watchOS 8.0+. On older OS versions, calls are silently ignored and a warning is logged.
:::

### 2. Track events from mediation callbacks

Wire every lifecycle callback, not only revenue. The two examples below show the pattern; the remaining methods take the same parameters:

#### Track ad loaded

Call when an ad successfully loads:

```swift
func onAdLoaded(ad: YourAdType) {
    Purchases.shared.adTracker.trackAdLoaded(.init(
        networkName: ad.networkName,        // e.g., "Google Ads"
        mediatorName: .appLovin,            // or custom: .init(value: "YourMediator")
        adFormat: .rewarded,                // .banner, .interstitial, etc.
        placement: "home_screen",           // Your custom placement ID
        adUnitId: ad.adUnitId,              // Ad unit identifier
        impressionId: ad.impressionId       // Unique impression ID
    ))
}
```

#### Track ad revenue

Call when your mediation platform reports revenue for an impression:

```swift
func onAdRevenue(ad: YourAdType, revenue: Double, currency: String) {
    Purchases.shared.adTracker.trackAdRevenue(.init(
        networkName: ad.networkName,
        mediatorName: .appLovin,
        adFormat: .rewarded,
        placement: "home_screen",
        adUnitId: ad.adUnitId,
        impressionId: ad.impressionId,
        revenueMicros: Int(revenue * 1_000_000), // Convert to micros
        currency: currency,                         // e.g., "USD"
        precision: .exact                           // Or .estimated, .publisherDefined
    ))
}
```

#### Wire the remaining callbacks

These follow the same pattern as `trackAdLoaded`. Displayed, opened, and failed to load are part of a complete integration: without them, Charts show revenue but no impressions, clicks, or fill rate. For rewarded ads, also track the earned reward and the prompt that offered the ad, so the rewarded funnel in Charts is complete.

- **`trackAdDisplayed(_:)`** - Call when ad impression is recorded (ad shown on screen)
- **`trackAdOpened(_:)`** - Call when user clicks/taps the ad
- **`trackAdFailedToLoad(_:)`** - Call when ad fails to load (doesn't require `networkName` or `impressionId`)
- **`trackAdRewardEarnedUnverified(_:)`** - Call when the ad SDK reports an earned reward; see [earned-reward tracking](#track-unverified-earned-rewards) for examples
- **`trackRewardedAdPromptShown(_:)` / `trackRewardedAdPromptAccepted(_:)`** - Rewarded ads only; see [Track rewarded ad prompts](#track-rewarded-ad-prompts)

See the [Event data reference](#event-data-reference) section below for complete parameter details.

## Flutter integration

:::tip[Using Google AdMob?]
The [AdMob adapter](https://www.revenuecat.com/docs/ad-monetization/admob) for Flutter tracks these events for you. Use the manual API below for other mediation platforms.
:::

### 1. Add the dependency

```yaml
# pubspec.yaml
dependencies:
  purchases_flutter: ^10.10.1
```

### 2. Access the AdTracker

```dart
import 'package:purchases_flutter/purchases_flutter.dart';

final adTracker = Purchases.adTracker;
```

:::info[iOS availability]
Ad tracking requires iOS 15.0+, tvOS 15.0+, macOS 12.0+, and watchOS 8.0+. On older OS versions, calls are silently ignored and a warning is logged. Android has no version restriction.
:::

### 3. Track events from mediation callbacks

Wire every lifecycle callback, not only revenue. The two examples below show the pattern; the remaining methods take the same parameters:

#### Track ad loaded

Call when an ad successfully loads:

```dart
void onAdLoaded(YourAdType ad) {
    Purchases.adTracker.trackAdLoaded(
        AdLoadedData(
            networkName: ad.networkName,         // e.g., "Google Ads"
            mediatorName: AdMediatorName.adMob,  // or custom: AdMediatorName('YourMediator')
            adFormat: AdFormat.rewarded,          // .banner, .interstitial, etc.
            placement: 'home_screen',             // Your custom placement ID
            adUnitId: ad.adUnitId,               // Ad unit identifier
            impressionId: ad.impressionId,       // Unique impression ID
        ),
    );
}
```

#### Track ad revenue

Call when your mediation platform reports revenue for an impression:

```dart
void onAdRevenue(YourAdType ad, double revenue, String currency) {
    Purchases.adTracker.trackAdRevenue(
        AdRevenueData(
            networkName: ad.networkName,
            mediatorName: AdMediatorName.adMob,
            adFormat: AdFormat.rewarded,
            placement: 'home_screen',
            adUnitId: ad.adUnitId,
            impressionId: ad.impressionId,
            revenueMicros: (revenue * 1_000_000).toInt(), // Convert to micros
            currency: currency,                            // e.g., "USD"
            precision: AdRevenuePrecision.exact,           // or .estimated, .publisherDefined
        ),
    );
}
```

#### Wire the remaining callbacks

These follow the same pattern as `trackAdLoaded`. Displayed, opened, and failed to load are part of a complete integration: without them, Charts show revenue but no impressions, clicks, or fill rate. For rewarded ads, also track the earned reward and the prompt that offered the ad, so the rewarded funnel in Charts is complete.

- **`trackAdDisplayed(AdDisplayedData)`** - Call when ad impression is recorded (ad shown on screen)
- **`trackAdOpened(AdOpenedData)`** - Call when user clicks/taps the ad
- **`trackAdFailedToLoad(AdFailedToLoadData)`** - Call when ad fails to load (doesn't require `networkName` or `impressionId`)
- **`trackAdRewardEarnedUnverified(AdRewardEarnedUnverifiedData)`** - Call when the ad SDK reports an earned reward; see [earned-reward tracking](#track-unverified-earned-rewards) for examples
- **`trackRewardedAdPromptShown` / `trackRewardedAdPromptAccepted`** - Rewarded ads only; see [Track rewarded ad prompts](#track-rewarded-ad-prompts)

See the [Event data reference](#event-data-reference) section below for complete parameter details.

## Unity integration

:::tip[Using Google AdMob?]
The [AdMob adapter](https://www.revenuecat.com/docs/ad-monetization/admob) for Unity tracks these events for you. Use the manual API below for other mediation platforms.
:::

### 1. Add the dependency

Import `com.revenuecat.purchases-unity` 9.9.0 or newer via the Unity Package Manager.

### 2. Access the AdTracker

```csharp
using RevenueCat;

var adTracker = purchases.AdTracker; // 'purchases' is the Purchases MonoBehaviour on a GameObject
```

:::info[iOS availability]
Ad tracking requires iOS 15.0+. On older iOS versions, calls are silently ignored and a warning is logged. The C# code compiles and runs on all platforms — the guard is applied in the native bridge layer.
:::

### 3. Track events from mediation callbacks

Wire every lifecycle callback, not only revenue. The two examples below show the pattern; the remaining methods take the same parameters:

#### Track ad loaded

Call when an ad successfully loads:

```csharp
void OnAdLoaded(YourAdType ad)
{
    purchases.AdTracker.TrackAdLoaded(new AdLoadedData(
        mediatorName: AdTracker.MediatorName.AdMob,  // or new AdTracker.MediatorName("YourMediator")
        adFormat: AdTracker.Format.Rewarded,          // .Banner, .Interstitial, etc.
        adUnitId: ad.adUnitId,                        // Ad unit identifier
        impressionId: ad.impressionId,                // Unique impression ID
        networkName: ad.networkName,                  // e.g., "Google Ads" (optional)
        placement: "home_screen"                      // Your custom placement ID (optional)
    ));
}
```

#### Track ad revenue

Call when your mediation platform reports revenue for an impression:

```csharp
void OnPaidEvent(YourAdType ad, double revenue, string currency)
{
    purchases.AdTracker.TrackAdRevenue(new AdRevenueData(
        mediatorName: AdTracker.MediatorName.AdMob,
        adFormat: AdTracker.Format.Rewarded,
        adUnitId: ad.adUnitId,
        impressionId: ad.impressionId,
        revenueMicros: (long)(revenue * 1_000_000),  // Convert to micros
        currency: currency,                           // e.g., "USD"
        precision: AdTracker.Precision.Exact          // or .Estimated, .PublisherDefined
    ));
}
```

#### Wire the remaining callbacks

These follow the same pattern as `TrackAdLoaded`. Displayed, opened, and failed to load are part of a complete integration: without them, Charts show revenue but no impressions, clicks, or fill rate. For rewarded ads, also track the earned reward and the prompt that offered the ad, so the rewarded funnel in Charts is complete.

- **`TrackAdDisplayed(AdDisplayedData)`** - Call when ad impression is recorded (ad shown on screen)
- **`TrackAdOpened(AdOpenedData)`** - Call when user clicks/taps the ad
- **`TrackAdFailedToLoad(AdFailedToLoadData)`** - Call when ad fails to load (doesn't require `networkName` or `impressionId`)
- **`TrackAdRewardEarnedUnverified(AdRewardEarnedUnverifiedData)`** - Call when the ad SDK reports an earned reward; see [earned-reward tracking](#track-unverified-earned-rewards) for examples
- **`TrackRewardedAdPromptShown` / `TrackRewardedAdPromptAccepted`** - Rewarded ads only; see [Track rewarded ad prompts](#track-rewarded-ad-prompts)

See the [Event data reference](#event-data-reference) section below for complete parameter details.

## React Native integration

:::tip[Using Google AdMob?]
The [AdMob adapter](https://www.revenuecat.com/docs/ad-monetization/admob) for React Native tracks these events for you. Use the manual API below for other mediation platforms.
:::

### 1. Add the dependency

```bash
npm install react-native-purchases@^10.8.1
# or
yarn add react-native-purchases@^10.8.1
```

### 2. Access the AdTracker

```jsx
import Purchases, {
  AdMediatorName,
  AdFormat,
  AdRevenuePrecision,
} from "react-native-purchases";

const adTracker = Purchases.adTracker;
```

:::info[Web and iOS availability]
Ad tracking is not supported on web — calls are silently ignored. On iOS \< 15.0, calls are also silently ignored and a warning is logged. Android has no version restriction.
:::

### 3. Track events from mediation callbacks

Wire every lifecycle callback, not only revenue. The two examples below show the pattern; the remaining methods take the same parameters:

#### Track ad loaded

Call when an ad successfully loads:

```jsx
async function onAdLoaded(ad: YourAdType) {
  await Purchases.adTracker.trackAdLoaded({
    networkName: ad.networkName, // e.g., "Google Ads" (optional)
    mediatorName: AdMediatorName.adMob, // or any string
    adFormat: AdFormat.rewarded, // AdFormat.banner, .interstitial, etc.
    placement: "home_screen", // Your custom placement ID (optional)
    adUnitId: ad.adUnitId, // Ad unit identifier
    impressionId: ad.impressionId, // Unique impression ID
  });
}
```

#### Track ad revenue

Call when your mediation platform reports revenue for an impression:

```jsx
async function onAdRevenue(ad: YourAdType, revenue: number, currency: string) {
  await Purchases.adTracker.trackAdRevenue({
    networkName: ad.networkName,
    mediatorName: AdMediatorName.adMob,
    adFormat: AdFormat.rewarded,
    placement: "home_screen",
    adUnitId: ad.adUnitId,
    impressionId: ad.impressionId,
    revenueMicros: Math.round(revenue * 1_000_000), // Convert to micros
    currency: currency, // e.g., "USD"
    precision: AdRevenuePrecision.exact, // or .estimated, .publisherDefined
  });
}
```

#### Wire the remaining callbacks

These follow the same pattern as `trackAdLoaded`. Displayed, opened, and failed to load are part of a complete integration: without them, Charts show revenue but no impressions, clicks, or fill rate. For rewarded ads, also track the earned reward and the prompt that offered the ad, so the rewarded funnel in Charts is complete.

- **`trackAdDisplayed(AdDisplayedData)`** - Call when ad impression is recorded (ad shown on screen)
- **`trackAdOpened(AdOpenedData)`** - Call when user clicks/taps the ad
- **`trackAdFailedToLoad(AdFailedToLoadData)`** - Call when ad fails to load (doesn't require `networkName` or `impressionId`)
- **`trackAdRewardEarnedUnverified(AdRewardEarnedUnverifiedData)`** - Call when the ad SDK reports an earned reward; see [earned-reward tracking](#track-unverified-earned-rewards) for examples
- **`trackRewardedAdPromptShown` / `trackRewardedAdPromptAccepted`** - Rewarded ads only; see [Track rewarded ad prompts](#track-rewarded-ad-prompts)

See the [Event data reference](#event-data-reference) section below for complete parameter details.

## Track rewarded ad prompts

Rewarded ads usually start with a prompt in your UI, such as a "Watch an ad to earn coins" button. Track that prompt to measure how many users see the offer and how many accept it before the ad loads:

- **Rewarded Ad Prompt Shown** - Call `trackRewardedAdPromptShown` when the prompt appears.
- **Rewarded Ad Prompt Accepted** - Call `trackRewardedAdPromptAccepted` when the user accepts the prompt (for example, taps the button).

Both events are **manual-only**: the [AdMob adapters](https://www.revenuecat.com/docs/ad-monetization/admob) never emit them, because only your app knows when the prompt is presented or accepted. Call them even if you use the adapter for the rest of the ad lifecycle.

Both events are **rewarded-only**: `adFormat` is always `rewarded` and is set for you. They take only `mediatorName`, `adUnitId`, and an optional `placement` — there is no `networkName` or `impressionId`, because the ad has not loaded yet.

**Swift**

```swift
// When the "Watch an ad to earn coins" prompt appears
func onRewardPromptShown() {
    Purchases.shared.adTracker.trackRewardedAdPromptShown(.init(
        mediatorName: .appLovin,            // or custom: .init(value: "YourMediator")
        placement: "bonus_coins_rewarded",  // Your custom placement ID
        adUnitId: rewardedAdUnitId          // Ad unit identifier
    ))
}

// When the user taps the prompt to watch the ad
func onRewardPromptAccepted() {
    Purchases.shared.adTracker.trackRewardedAdPromptAccepted(.init(
        mediatorName: .appLovin,
        placement: "bonus_coins_rewarded",
        adUnitId: rewardedAdUnitId
    ))
}
```

**Kotlin**

```kotlin
// When the "Watch an ad to earn coins" prompt appears
fun onRewardPromptShown() {
    adTracker.trackRewardedAdPromptShown(
        AdRewardPromptShownData(
            mediatorName = AdMediatorName.APP_LOVIN,  // or custom: AdMediatorName.fromString("YourMediator")
            placement = "bonus_coins_rewarded",      // Your custom placement ID
            adUnitId = rewardedAdUnitId              // Ad unit identifier
        )
    )
}

// When the user taps the prompt to watch the ad
fun onRewardPromptAccepted() {
    adTracker.trackRewardedAdPromptAccepted(
        AdRewardPromptAcceptedData(
            mediatorName = AdMediatorName.APP_LOVIN,
            placement = "bonus_coins_rewarded",
            adUnitId = rewardedAdUnitId
        )
    )
}
```

**Flutter**

```dart
// When the "Watch an ad to earn coins" prompt appears
void onRewardPromptShown() {
    Purchases.adTracker.trackRewardedAdPromptShown(
        AdRewardPromptShownData(
            mediatorName: AdMediatorName.appLovin,  // or custom: AdMediatorName('YourMediator')
            placement: 'bonus_coins_rewarded',      // Your custom placement ID
            adUnitId: rewardedAdUnitId,             // Ad unit identifier
        ),
    );
}

// When the user taps the prompt to watch the ad
void onRewardPromptAccepted() {
    Purchases.adTracker.trackRewardedAdPromptAccepted(
        AdRewardPromptAcceptedData(
            mediatorName: AdMediatorName.appLovin,
            placement: 'bonus_coins_rewarded',
            adUnitId: rewardedAdUnitId,
        ),
    );
}
```

**Unity**

```csharp
// When the "Watch an ad to earn coins" prompt appears
void OnRewardPromptShown()
{
    purchases.AdTracker.TrackRewardedAdPromptShown(new AdRewardPromptShownData(
        mediatorName: AdTracker.MediatorName.AppLovin,  // or new AdTracker.MediatorName("YourMediator")
        adUnitId: rewardedAdUnitId,                     // Ad unit identifier
        placement: "bonus_coins_rewarded"               // Your custom placement ID (optional)
    ));
}

// When the user taps the prompt to watch the ad
void OnRewardPromptAccepted()
{
    purchases.AdTracker.TrackRewardedAdPromptAccepted(new AdRewardPromptAcceptedData(
        mediatorName: AdTracker.MediatorName.AppLovin,
        adUnitId: rewardedAdUnitId,
        placement: "bonus_coins_rewarded"
    ));
}
```

**React Native**

```jsx
// When the "Watch an ad to earn coins" prompt appears
async function onRewardPromptShown() {
  await Purchases.adTracker.trackRewardedAdPromptShown({
    mediatorName: AdMediatorName.appLovin, // or any string
    placement: "bonus_coins_rewarded", // Your custom placement ID (optional)
    adUnitId: rewardedAdUnitId, // Ad unit identifier
  });
}

// When the user taps the prompt to watch the ad
async function onRewardPromptAccepted() {
  await Purchases.adTracker.trackRewardedAdPromptAccepted({
    mediatorName: AdMediatorName.appLovin,
    placement: "bonus_coins_rewarded",
    adUnitId: rewardedAdUnitId,
  });
}
```

## Track unverified earned rewards

Call `trackAdRewardEarnedUnverified` from your ad SDK's earned-reward callback when you integrate rewarded ads without RevenueCat reward verification. In Unity, use `TrackAdRewardEarnedUnverified`.

This event records that the ad SDK reported an earned reward. It doesn't verify the reward or grant in-app currency or entitlements. Use it for rewarded or rewarded interstitial ads, with the same `impressionId` you use for the ad's other events.

If you use the AdMob adapter's reward verification, or pass tracking metadata to `pollRewardVerification`, the SDK tracks this event automatically. Calling it manually as well would duplicate the event. See [Granting Ad Rewards](https://www.revenuecat.com/docs/ad-monetization/rewards) to set up verified rewards.

### Track from the earned-reward callback

Use the same ad context as your other tracking calls. In Swift, the payload type is `AdRewardEarnedUnverified`; the other SDKs use `AdRewardEarnedUnverifiedData`.

**Swift**

```swift
func onUserEarnedReward(ad: YourAdType) {
    Purchases.shared.adTracker.trackAdRewardEarnedUnverified(.init(
        networkName: ad.networkName,
        mediatorName: .appLovin,
        adFormat: .rewarded,
        placement: "bonus_coins_rewarded",
        adUnitId: ad.adUnitId,
        impressionId: ad.impressionId
    ))
}
```

**Kotlin**

```kotlin
import com.revenuecat.purchases.ads.events.types.AdFormat
import com.revenuecat.purchases.ads.events.types.AdMediatorName
import com.revenuecat.purchases.ads.events.types.AdRewardEarnedUnverifiedData

fun onUserEarnedReward(ad: YourAdType) {
    adTracker.trackAdRewardEarnedUnverified(
        AdRewardEarnedUnverifiedData(
            networkName = ad.networkName,
            mediatorName = AdMediatorName.APP_LOVIN,
            adFormat = AdFormat.REWARDED,
            placement = "bonus_coins_rewarded",
            adUnitId = ad.adUnitId,
            impressionId = ad.impressionId,
        )
    )
}
```

**Kotlin MP**

```kotlin
import com.revenuecat.purchases.kmp.Purchases
import com.revenuecat.purchases.kmp.models.AdFormat
import com.revenuecat.purchases.kmp.models.AdMediatorName
import com.revenuecat.purchases.kmp.models.AdRewardEarnedUnverifiedData

fun onUserEarnedReward(ad: YourAdType) {
    Purchases.sharedInstance.adTracker.trackAdRewardEarnedUnverified(
        AdRewardEarnedUnverifiedData(
            networkName = ad.networkName,
            mediatorName = AdMediatorName.AD_MOB,
            adFormat = AdFormat.REWARDED,
            placement = "bonus_coins_rewarded",
            adUnitId = ad.adUnitId,
            impressionId = ad.impressionId,
        )
    )
}
```

**Flutter**

```dart
Future<void> onUserEarnedReward(YourAdType ad) async {
    await Purchases.adTracker.trackAdRewardEarnedUnverified(
        AdRewardEarnedUnverifiedData(
            networkName: ad.networkName,
            mediatorName: AdMediatorName.adMob,
            adFormat: AdFormat.rewarded,
            placement: 'bonus_coins_rewarded',
            adUnitId: ad.adUnitId,
            impressionId: ad.impressionId,
        ),
    );
}
```

**React Native**

```jsx
async function onUserEarnedReward(ad: YourAdType) {
  await Purchases.adTracker.trackAdRewardEarnedUnverified({
    networkName: ad.networkName,
    mediatorName: AdMediatorName.adMob,
    adFormat: AdFormat.rewarded,
    placement: "bonus_coins_rewarded",
    adUnitId: ad.adUnitId,
    impressionId: ad.impressionId,
  });
}
```

**Unity**

```csharp
void OnUserEarnedReward(YourAdType ad)
{
    purchases.AdTracker.TrackAdRewardEarnedUnverified(new AdRewardEarnedUnverifiedData(
        mediatorName: AdTracker.MediatorName.AdMob,
        adFormat: AdTracker.Format.Rewarded,
        adUnitId: ad.adUnitId,
        impressionId: ad.impressionId,
        networkName: ad.networkName,
        placement: "bonus_coins_rewarded"
    ));
}
```

## Event data reference

### Common parameters

The ad lifecycle events (loaded, displayed, opened, revenue, failed to load, and earned reward) share these common parameters:

| Parameter      | Type           | Description                                                                 | Required                       |
| -------------- | -------------- | --------------------------------------------------------------------------- | ------------------------------ |
| `networkName`  | String         | Ad network that served the ad (e.g., "Google Ads", "Meta Audience Network") | No (null allowed)              |
| `mediatorName` | AdMediatorName | Your mediation platform                                                     | Yes                            |
| `adFormat`     | AdFormat       | Type of ad                                                                  | Yes                            |
| `placement`    | String         | Your custom placement identifier                                            | No (null allowed)              |
| `adUnitId`     | String         | Ad unit identifier from mediation platform                                  | Yes                            |
| `impressionId` | String         | Unique identifier for this ad instance                                      | Yes (except for failed events) |

Rewarded ad prompt events accept only `mediatorName`, `adUnitId`, and an optional `placement`. They have no `adFormat`, `networkName`, or `impressionId` parameter; the SDK sets `adFormat` to `rewarded` for you.

### AdFormat values

| Format                | Android                          | iOS                     | Flutter                         | Unity                                   | React Native                    |
| --------------------- | -------------------------------- | ----------------------- | ------------------------------- | --------------------------------------- | ------------------------------- |
| Banner                | `AdFormat.BANNER`                | `.banner`               | `AdFormat.banner`               | `AdTracker.Format.Banner`               | `AdFormat.banner`               |
| Interstitial          | `AdFormat.INTERSTITIAL`          | `.interstitial`         | `AdFormat.interstitial`         | `AdTracker.Format.Interstitial`         | `AdFormat.interstitial`         |
| Rewarded              | `AdFormat.REWARDED`              | `.rewarded`             | `AdFormat.rewarded`             | `AdTracker.Format.Rewarded`             | `AdFormat.rewarded`             |
| Rewarded Interstitial | `AdFormat.REWARDED_INTERSTITIAL` | `.rewardedInterstitial` | `AdFormat.rewardedInterstitial` | `AdTracker.Format.RewardedInterstitial` | `AdFormat.rewardedInterstitial` |
| Native                | `AdFormat.NATIVE`                | `.native`               | `AdFormat.native_`              | `AdTracker.Format.Native`               | `AdFormat.native`               |
| App Open              | `AdFormat.APP_OPEN`              | `.appOpen`              | `AdFormat.appOpen`              | `AdTracker.Format.AppOpen`              | `AdFormat.appOpen`              |
| Other                 | `AdFormat.OTHER`                 | `.other`                | `AdFormat.other`                | `AdTracker.Format.Other`                | `AdFormat.other`                |
| Custom                | `AdFormat.fromString("x")`       | `.init(value: "x")`     | `AdFormat("x")`                 | `new AdTracker.Format("x")`             | any string                      |

### AdMediatorName values

| Mediator        | Android                          | iOS                         | Flutter                       | Unity                                     | React Native              |
| --------------- | -------------------------------- | --------------------------- | ----------------------------- | ----------------------------------------- | ------------------------- |
| Google AdMob    | `AdMediatorName.AD_MOB`          | `.adMob`                    | `AdMediatorName.adMob`        | `AdTracker.MediatorName.AdMob`            | `AdMediatorName.adMob`    |
| AppLovin MAX    | `AdMediatorName.APP_LOVIN`       | `.appLovin`                 | `AdMediatorName.appLovin`     | `AdTracker.MediatorName.AppLovin`         | `AdMediatorName.appLovin` |
| Unity LevelPlay | `AdMediatorName.LEVEL_PLAY`      | `.init(value: "LevelPlay")` | `AdMediatorName("LevelPlay")` | `new AdTracker.MediatorName("LevelPlay")` | `"LevelPlay"`             |
| Custom          | `AdMediatorName.fromString("x")` | `.init(value: "x")`         | `AdMediatorName("x")`         | `new AdTracker.MediatorName("x")`         | any string                |

On Android SDK versions that don't expose `AdMediatorName.LEVEL_PLAY`, use `AdMediatorName.fromString("LevelPlay")`.

### AdRevenuePrecision values

| Precision         | Android                                | iOS                 | Flutter                               | Unity                                  | React Native                          |
| ----------------- | -------------------------------------- | ------------------- | ------------------------------------- | -------------------------------------- | ------------------------------------- |
| Exact             | `AdRevenuePrecision.EXACT`             | `.exact`            | `AdRevenuePrecision.exact`            | `AdTracker.Precision.Exact`            | `AdRevenuePrecision.exact`            |
| Estimated         | `AdRevenuePrecision.ESTIMATED`         | `.estimated`        | `AdRevenuePrecision.estimated`        | `AdTracker.Precision.Estimated`        | `AdRevenuePrecision.estimated`        |
| Publisher Defined | `AdRevenuePrecision.PUBLISHER_DEFINED` | `.publisherDefined` | `AdRevenuePrecision.publisherDefined` | `AdTracker.Precision.PublisherDefined` | `AdRevenuePrecision.publisherDefined` |
| Unknown           | `AdRevenuePrecision.UNKNOWN`           | `.unknown`          | `AdRevenuePrecision.unknown`          | `AdTracker.Precision.Unknown`          | `AdRevenuePrecision.unknown`          |

### Revenue in micros

The `revenueMicros` parameter expects revenue in **micros** (millionths of the currency unit). Multiply the revenue value from your mediation platform by 1,000,000:

- $1.50 USD → `1,500,000` micros
- €0.25 EUR → `250,000` micros

The conversion in each platform's code examples above shows the exact formula for that language.

## Best practices

### Placement naming

Use consistent, descriptive placement names:

- ✅ Good: `"home_banner"`, `"level_complete_interstitial"`, `"bonus_coins_rewarded"`
- ❌ Avoid: `"ad1"`, `"test"`, timestamps, or dynamic values

### Impression IDs

- Use unique IDs provided by your mediation platform
- Use the same impression ID across all events for a single ad instance (loaded → displayed → opened → revenue)
- Include the same impression ID when tracking an earned reward for that ad
- Prompt events have no impression ID because they fire before the ad loads

### Error handling

Track failed ad loads to understand fill rate issues:

```kotlin
adTracker.trackAdFailedToLoad(
    AdFailedToLoadData(
        mediatorName = AdMediatorName.fromString("YourMediator"),
        adFormat = AdFormat.REWARDED,
        placement = "home_screen",
        adUnitId = adUnitId,
        mediatorErrorCode = errorCode // Include platform error code
    )
)
```

### When to track each event

| Event                           | When to Call                                                                     |
| ------------------------------- | -------------------------------------------------------------------------------- |
| `trackAdLoaded`                 | After ad successfully loads in memory                                            |
| `trackAdDisplayed`              | When ad impression is recorded (ad shown on screen)                              |
| `trackAdOpened`                 | When user clicks/taps the ad                                                     |
| `trackAdRevenue`                | When mediation platform reports ILRD for the impression                          |
| `trackAdFailedToLoad`           | When ad request fails                                                            |
| `trackAdRewardEarnedUnverified` | When the ad SDK reports an earned reward, without RevenueCat reward verification |
| `trackRewardedAdPromptShown`    | When your UI shows a prompt offering a rewarded ad                               |
| `trackRewardedAdPromptAccepted` | When the user accepts the prompt to watch the ad                                 |

## Before you finish

Check each item before you ship. Every one of them is a mistake we have seen in production integrations.

- All five lifecycle events are wired: loaded, displayed, opened, revenue, and failed to load. A revenue-only integration shows revenue but no impressions, clicks, or fill rate.
- Rewarded ads also track `trackRewardedAdPromptShown`, `trackRewardedAdPromptAccepted`, and `trackAdRewardEarnedUnverified` (see [Track rewarded ad prompts](#track-rewarded-ad-prompts) and [Track unverified earned rewards](#track-unverified-earned-rewards)). Without them, the rewarded funnel in Charts stops at the impression.
- Every call passes a `placement`, including loaded and failed to load. Loads without a placement are reported under "Unknown placement", and your named placements show a 0% fill rate.
- Each ad instance has one `impressionId`, shared by its loaded, displayed, opened, and revenue events.
- Revenue is converted to micros exactly once. Converting a value that is already in micros reports eCPM a million times too high.
- `trackAdOpened` is called when the user taps the ad, not when the ad is shown. Wiring it to the impression callback reports a click-through rate near 100%.
- `trackAdRevenue` is called once per impression, from the revenue callback only. Calling it at impression time as well doubles the event count.
- Impression-level ad revenue is enabled and saved in your mediation platform. Without it, no revenue events arrive.
- A debug build shows every event type in the sandbox data view on the Ads page (see [Testing your integration](#testing-your-integration)).

## Example projects

Complete working examples are available:

- **Android**: [Unity LevelPlay manual integration](https://github.com/RevenueCat/purchases-android/tree/main/examples/vanilla-ad-tracker-sample) — Tracks banner, interstitial, rewarded, and failed-load events without an adapter
- **iOS**: [AdMob integration](https://github.com/RevenueCat/purchases-ios/tree/main/Projects/AdMobIntegrationSample) — Shows AdMob integration patterns

## View your data

See the [Ad Monetization overview](https://www.revenuecat.com/docs/ad-monetization#data-availability) for details on where your ad data appears in the dashboard.

## Troubleshooting

### Testing your integration

Before troubleshooting, verify your events are being tracked:

1. Run your app in **debug mode**
2. Navigate to the **Ads page** in your RevenueCat dashboard
3. Toggle on **"Sandbox data"**
4. Trigger some ads in your app
5. Check that events appear in the sandbox events table

RevenueCat automatically marks events from debug builds as sandbox, so you can verify your integration without affecting production data.

### Events not appearing in Charts

1. Verify you've opted in via the Ads page in your RevenueCat dashboard
2. Check that you're calling the correct `track*` methods with all required parameters
3. Ensure `impressionId` is unique for each ad instance (prompt events have no `impressionId`)
4. Verify your mediation platform is providing ILRD callbacks
5. Check that `revenueMicros` is calculated correctly (multiply by 1,000,000)
6. Use the sandbox data view (above) to confirm events are being received

### Revenue values seem incorrect

- Ensure you're converting to micros: multiply by 1,000,000
- Verify the currency code is correct (e.g., "USD", "EUR")
- Check that the revenue value from your mediation platform is already in the correct currency unit

## Next steps

- Review the [example projects](#example-projects) for complete implementations
- View your ad data in [Ad Charts](https://www.revenuecat.com/docs/dashboard-and-metrics/charts/ads)
- Learn about the [AdMob SDK Integration](https://www.revenuecat.com/docs/ad-monetization/admob) for simplified integration with Google AdMob on iOS, Android, Flutter, React Native, and Unity
