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

# AppLovin MAX

<Info>
  **Note**

  This feature is currently in beta. If you have any questions or suggestions for improvements, reach out to your Airbridge CSM. If you don't have a dedicated CSM, contact us through the [Airbridge Help Center](https://app.airbridge.io/supports).
</Info>

Airbridge supports server-to-server (S2S) and SDK integration with AppLovin MAX. With the integration, you can import the ad revenue into Airbridge.

<Note>
  **Recommended integration method**

  We recommend implementing both S2S integration and SDK integration for more accurate measurement.

  Make sure to check the [version of the SDK](/en/guides/applovin-max#pre-setup) you installed before implementing both S2S integration and SDK integration. You must have a certain version or later of the installed SDK to set up all integrations properly. If your SDK version is earlier than the required version, the user count will not be accurately aggregated after integration.

  Airbridge automatically updates the data received through SDK integration in real-time with the enriched data received through S2S integration. The data received through SDK integration can also be used to set up SKAN conversion values.
</Note>

## Prerequisite

Check the Airbridge SDK version installed in the app. If it is earlier than the versions listed below, proceed with only S2S integration or only SDK integration.

<Danger>
  **Attention**

  If you want to proceed with both S2S and SDK integrations, make sure the Airbridge SDK version installed in the app meets the requirements.

  It is advised to proceed with the integrations once a sufficient number of users have updated their app to the version with the required Airbridge SDK version. If most of your users still have the app with the Airbridge SDK version earlier than the required version, the user count may not be accurately aggregated in Airbridge.
</Danger>

* Android SDK 2.25.0
* iOS SDK 1.37.3
* React Native SDK 2.8.6
* Flutter SDK 3.5.6
* Cordova SDK 2.6.6
* Expo SDK 2.6.6
* Unity SDK 1.14.5
* Unreal SDK 1.3.5

## SDK Integration

Click the link below and install the AppLovin MAX SDK.

* [Android SDK install guide](https://developers.applovin.com/en/max/android/overview/integration/) of AppLovin MAX
* [iOS SDK install guide](https://developers.applovin.com/en/max/ios/overview/integration/) of AppLovin MAX
* [React Native SDK install guide](https://developers.applovin.com/en/max/react-native/overview/integration/) of AppLovin MAX
* [Unity SDK install guide](https://developers.applovin.com/en/max/unity/overview/integration/) of AppLovin MAX

### Send data to Airbridge

Configure the ad revenue data callback `OnAdRevenuePaidEvent` to send the ad revenue data to the Airbridge SDK.

<AccordionGroup>
  <Accordion title="SDK integration (Android)">
    #### Android SDK

    <CodeGroup>
      ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      override fun onAdRevenuePaid(maxAd: MaxAd) {
          Airbridge.trackEvent(
              AirbridgeCategory.AD_IMPRESSION,
              mapOf(
                  AirbridgeAttribute.ACTION to maxAd.networkName,
                  AirbridgeAttribute.LABEL to maxAd.networkPlacement,
                  AirbridgeAttribute.VALUE to maxAd.revenue,
                  AirbridgeAttribute.AD_PARTNERS to mapOf(
                      "appLovin" to mapOf(
                          "revenue" to maxAd.revenue,
                          "country_code" to AppLovinSdk.getInstance(this).configuration.countryCode,
                          "network_name" to maxAd.networkName,
                          "network_placement" to maxAd.networkPlacement,
                          "adunit_identifier" to maxAd.adUnitId,
                          "creative_identifier" to maxAd.creativeId,
                          "placement" to maxAd.placement,
                          "ad_revenue_format" to maxAd.format.label,
                          "ad_revenue_precision" to maxAd.revenuePrecision
                      )
                  ),
                  // AppLovin MAX has a default currency of USD
                  AirbridgeAttribute.CURRENCY to "USD"
              )
          )
      }
      ```

      ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      @Override
      public void onAdRevenuePaid(final MaxAd maxAd) {

          String countryCode = AppLovinSdk.getInstance(this).getConfiguration().getCountryCode();
          String adFormat = maxAd.getFormat().getLabel();
          String precision = maxAd.getRevenuePrecision();

          Airbridge.trackEvent(
                  AirbridgeCategory.AD_IMPRESSION,
                  new HashMap<String, Object>() {{
                      put(AirbridgeAttribute.ACTION, maxAd.getNetworkName());
                      put(AirbridgeAttribute.LABEL, maxAd.getNetworkPlacement());
                      put(AirbridgeAttribute.VALUE, maxAd.getRevenue());
                      put(AirbridgeAttribute.AD_PARTNERS, new HashMap<String, Object>() {{
                          put("appLovin", new HashMap<String, Object>() {{
                              put("revenue", maxAd.getRevenue());
                              put("country_code", countryCode);
                              put("network_name", maxAd.getNetworkName());
                              put("network_placement", maxAd.getNetworkPlacement());
                              put("adunit_identifier", maxAd.getAdUnitId());
                              put("creative_identifier", maxAd.getCreativeId());
                              put("placement", maxAd.getPlacement());
                              put("ad_revenue_format", adFormat);
                              put("ad_revenue_precision", precision);
                          }});
                      }});
                      // AppLovin MAX has a default currency of USD
                      put(AirbridgeAttribute.CURRENCY, "USD");
                  }}
          );
      }
      ```
    </CodeGroup>

    #### Android SDK (Deprecated)

    <CodeGroup>
      ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      override fun onAdRevenuePaid(ad: MaxAd) {

          val event = Event("airbridge.adImpression")

          val appLovin = mutableMapOf<String, Any?>()
          appLovin["revenue"] = ad.revenue
          appLovin["country_code"] = AppLovinSdk.getInstance(this).configuration.countryCode
          appLovin["network_name"] = ad.networkName
          appLovin["network_placement"] = ad.networkPlacement
          appLovin["adunit_identifier"] = ad.adUnitId
          appLovin["creative_identifier"] = ad.creativeId
          appLovin["placement"] = ad.placement
          appLovin["ad_revenue_format"] = ad.format.label
          appLovin["ad_revenue_precision"] = ad.revenuePrecision

          val adPartners = mapOf("appLovin" to appLovin)

          event.action = ad.networkName
          event.label = ad.networkPlacement
          event.value = ad.revenue
          event.semanticAttributes = mutableMapOf(
              "adPartners" to adPartners,
              // AppLovin MAX has a default currency of USD
              "currency" to "USD"
          )
          Airbridge.trackEvent(event)
      }
      ```

      ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      @Override
      public void onAdRevenuePaid(final MaxAd maxAd)
      {
          Event event = new Event("airbridge.adImpression");
          
          Map<String, Object> appLovin = new HashMap<>();
          appLovin.put("revenue", maxAd.getRevenue());
          appLovin.put("country_code", AppLovinSdk.getInstance(this).getConfiguration().getCountryCode());
          appLovin.put("network_name", maxAd.getNetworkName());
          appLovin.put("network_placement", maxAd.getNetworkPlacement());
          appLovin.put("adunit_identifier", maxAd.getAdUnitId());
          appLovin.put("creative_identifier", maxAd.getCreativeId());
          appLovin.put("placement", maxAd.getPlacement());
          appLovin.put("ad_revenue_format", maxAd.getFormat().getLabel());
          appLovin.put("ad_revenue_precision", maxAd.getRevenuePrecision());

          Map<String, Object> adPartners = new HashMap<>();
          adPartners.put("appLovin", appLovin);

          Map<String, Object> semanticAttributes = new HashMap<>();
          semanticAttributes.put("adPartners", adPartners);
          // AppLovin MAX has a default currency of USD
          semanticAttributes.put("currency", "USD");

          event.setAction(maxAd.getNetworkName());
          event.setLabel(maxAd.getNetworkPlacement());
          event.setValue(maxAd.getRevenue());
          event.setSemanticAttributes(semanticAttributes);
          Airbridge.trackEvent(event);
      }
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="SDK integration (iOS)">
    #### iOS SDK

    <CodeGroup>
      ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      class ExampleViewController : UIViewController {
          func createNativeAdLoader() {
              nativeAdLoader?.revenueDelegate = self;
          }
      }

      extension ExampleViewController: MAAdRevenueDelegate {
          func didPayRevenue(for ad: MAAd) {
              Airbridge.trackEvent(
                  category: AirbridgeCategory.AD_IMPRESSION,
                  semanticAttributes: [
                      AirbridgeAttribute.ACTION: ad.networkName,
                      AirbridgeAttribute.LABEL: ad.networkPlacement,
                      AirbridgeAttribute.VALUE: ad.revenue,
                      AirbridgeAttribute.AD_PARTNERS: [
                          "appLovin": [
                              "revenue": ad.revenue,
                              "country_code": ALSdk.shared().configuration.countryCode,
                              "network_name": ad.networkName,
                              "network_placement": ad.networkPlacement,
                              "adunit_identifier": ad.adUnitIdentifier,
                              "creative_identifier": ad.creativeIdentifier,
                              "placement": ad.placement,
                              "ad_revenue_format": ad.format.label,
                              "ad_revenue_precision": ad.revenuePrecision
                          ]
                      ],
                      AirbridgeAttribute.CURRENCY: "USD"
                  ]
              )
          }
      }
      ```

      ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      @implementation ExampleViewController

      - (void)createNativeAdLoader {
          self.nativeAdLoader.revenueDelegate = self;
      }

      - (void)didPayRevenueForAd:(MAAd *)ad {
      	[Airbridge trackEventWithCategory:AirbridgeCategory.AD_IMPRESSION semanticAttributes:@{
              AirbridgeAttribute.ACTION: ad.networkName,
              AirbridgeAttribute.LABEL: ad.networkPlacement,
              AirbridgeAttribute.VALUE: @(ad.revenue),
              AirbridgeAttribute.AD_PARTNERS: @{
                  @"appLovin": @{
                      @"revenue": @(ad.revenue),
                      @"country_code": [ALSdk shared].configuration.countryCode,
                      @"network_name": ad.networkName,
                      @"network_placement": ad.networkPlacement,
                      @"adunit_identifier": ad.adUnitIdentifier,
                      @"creative_identifier": ad.creativeIdentifier,
                      @"placement": ad.placement,
                      @"ad_revenue_format": ad.format.label,
                      @"ad_revenue_precision": ad.revenuePrecision
                  }
              },
              AirbridgeAttribute.CURRENCY: @"USD"
          }];
      }
      ```
    </CodeGroup>

    #### iOS SDK (Deprecated)

    <CodeGroup>
      ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      class ExampleViewController : UIViewController {
          func createNativeAdLoader() {
              nativeAdLoader?.revenueDelegate = self
          }
      }

      extension ExampleViewController: MAAdRevenueDelegate {
          func didPayRevenue(for ad: MAAd) {
              let event = ABInAppEvent()
              event?.setCategory("airbridge.adImpression")
              event?.setAction(ad.networkName)
              event?.setLabel(ad.networkPlacement)
              event?.setValue(ad.revenue)
              event?.setSemantics([
                  "adPartners": [
                      "appLovin": [
                          "revenue": ad.revenue,
                          "country_code": ALSdk.shared().configuration.countryCode,
                          "network_name": ad.networkName,
                          "network_placement": ad.networkPlacement,
                          "adunit_identifier": ad.adUnitIdentifier,
                          "creative_identifier": ad.creativeIdentifier,
                          "placement": ad.placement,
                          "ad_revenue_format": ad.format.label,
                          "ad_revenue_precision": ad.revenuePrecision
                      ]
                  ],
                  "currency": "USD"
              ])

              event?.send()
          }
      }
      ```

      ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      @implementation ExampleViewController

      - (void)createNativeAdLoader {
      	self.nativeAdLoader.revenueDelegate = self;
      }

      - (void)didPayRevenueForAd:(MAAd *)ad {
      	ABInAppEvent* event = [[ABInAppEvent alloc] init];
      	[event setCategory:@"airbridge.adImpression"];
      	[event setAction:ad.networkName];
      	[event setLabel:ad.networkPlacement];
      	[event setValue:ad.revenue];
      	[event setSemantics:@{
      		@"adPartners": @{
      			@"appLovin": @{
      				@"revenue": @(ad.revenue),
      				@"country_code": [ALSdk shared].configuration.countryCode,
      				@"network_name": ad.networkName,
      				@"network_placement": ad.networkPlacement,
      				@"adunit_identifier": ad.adUnitIdentifier,
      				@"creative_identifier": ad.creativeIdentifier,
      				@"placement": ad.placement,
      				@"ad_revenue_format": ad.format.label,
                      @"ad_revenue_precision": ad.revenuePrecision
      			}
      		},
      		@"currency": @"USD"
      	}];

      	[event send];
      }
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="SDK integration (React Native)">
    #### React Native SDK

    <CodeGroup>
      ```javascript JavaScript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      function App(): JSX.Element {
          useEffect(() => {
              // Helper function to add an ad revenue paid listener
              const addAdRevenuePaidListener = (AdClass) => {
                  AdClass.addAdRevenuePaidListener(adInfo => {
                      if (adInfo) {
                          onAdRevenuePaidEvent(adInfo);
                      }
                  });
              };

              // Set up event listeners
              [BannerAd, InterstitialAd, RewardedAd, AppOpenAd, MRecAd].forEach(addAdRevenuePaidListener);
          }, []);

          const onAdRevenuePaidEvent = (adInfo: AdRevenueInfo) => {
              Airbridge.trackEvent(
                  AirbridgeCategory.AD_IMPRESSION, {
                      [AirbridgeAttribute.ACTION]: adInfo.networkName,
                      [AirbridgeAttribute.LABEL]: adInfo.networkPlacement,
                      [AirbridgeAttribute.VALUE]: adInfo.revenue,
                      [AirbridgeAttribute.AD_PARTNERS]: {
                          'appLovin': {
                              'revenue': adInfo.revenue,
                              'country_code': adInfo.countryCode,
                              'network_name': adInfo.networkName,
                              'network_placement': adInfo.networkPlacement,
                              'adunit_identifier': adInfo.adUnitId,
                              'creative_identifier': adInfo.creativeId,
                              'placement': adInfo.placement,
                              'ad_revenue_format': adInfo.adFormat,
                              'ad_revenue_precision': adInfo.revenuePrecision
                          }
                      },
                      [AirbridgeAttribute.CURRENCY]: 'USD',
                  }
              );
          };

          return ({
              /* Your JSX goes here */
          });
      }
      ```
    </CodeGroup>

    #### React Native SDK (Deprecated)

    <CodeGroup>
      ```javascript JavaScript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      function App(): JSX.Element {
          useEffect(() => {
              // Helper function to add an ad revenue paid listener
              const addAdRevenuePaidListener = (AdClass) => {
                  AdClass.addAdRevenuePaidListener(adInfo => {
                      if (adInfo) {
                          onAdRevenuePaidEvent(adInfo);
                      }
                  });
              };

              // Set up event listeners
              [BannerAd, InterstitialAd, RewardedAd, AppOpenAd, MRecAd].forEach(addAdRevenuePaidListener);
          }, []);

          const onAdRevenuePaidEvent = (adInfo: AdRevenueInfo) => {
              const airbridgeSemanticAttributes = {
                  adPartners: {
                      appLovin: {
                          revenue: adInfo.revenue,
                          country_code: adInfo.countryCode,
                          network_name: adInfo.networkName,
                          network_placement: adInfo.networkPlacement,
                          adunit_identifier: adInfo.adUnitId,
                          creative_identifier: adInfo.creativeId,
                          placement: adInfo.placement,
                          ad_revenue_format: adInfo.adFormat,
                          ad_revenue_precision: adInfo.revenuePrecision
                      },
                  },
                  currency: 'USD', // Assuming USD as default
              }

              Airbridge.trackEvent('airbridge.adImpression', {
                  action: adInfo.networkName,
                  label: adInfo.networkPlacement,
                  value: adInfo.revenue,
                  semanticAttributes: airbridgeSemanticAttributes
              });
          };

          return ({
              /* Your JSX goes here */
          });
      }
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="SDK integration (Unity)">
    #### Unity SDK

    <CodeGroup>
      ```c# C# lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      private void OnEnable() 
      {
          MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
          MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
          MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
          MaxSdkCallbacks.RewardedInterstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
          MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
      }

      private void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
      {
          if (adInfo == null) {
              return;
          }

          Airbridge.TrackEvent(
              category: AirbridgeCategory.AD_IMPRESSION,
              semanticAttributes: new Dictionary<string, object>()
              {
                  { AirbridgeAttribute.ACTION, adInfo.NetworkName },
                  { AirbridgeAttribute.LABEL, adInfo.NetworkPlacement },
                  { AirbridgeAttribute.VALUE, adInfo.Revenue },
                  { AirbridgeAttribute.CURRENCY, "USD" },
                  {
                      AirbridgeAttribute.AD_PARTNERS, new Dictionary<string, object>()
                      {
                          {
                              "appLovin", new Dictionary<string, object>()
                              {
                                  { "revenue", adInfo.Revenue },
                                  { "country_code", MaxSdk.GetSdkConfiguration().CountryCode },
                                  { "network_name", adInfo.NetworkName },
                                  { "network_placement", adInfo.NetworkPlacement },
                                  { "adunit_identifier", adInfo.AdUnitIdentifier },
                                  { "creative_identifier", adInfo.CreativeIdentifier },
                                  { "placement", adInfo.Placement },
                                  { "ad_revenue_format", adInfo.AdFormat },
                                  { "ad_revenue_precision", adInfo.RevenuePrecision }
                              }
                          }
                      }
                  },
              }
          );
      }
      ```
    </CodeGroup>

    #### Unity SDK (Deprecated)

    <CodeGroup>
      ```c# C# lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      private void OnEnable()
      {
          MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
          MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
          MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
          MaxSdkCallbacks.RewardedInterstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
          MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
      }

      private void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
      {
          if (adInfo != null) {
              AirbridgeEvent @event = new AirbridgeEvent("airbridge.adImpression");

              var appLovin = new Dictionary<string, object>();
              appLovin["revenue"] = adInfo.Revenue;
              appLovin["country_code"] = MaxSdk.GetSdkConfiguration().CountryCode;
              appLovin["network_name"] = adInfo.NetworkName;
              appLovin["network_placement"] = adInfo.NetworkPlacement;
              appLovin["adunit_identifier"] = adInfo.AdUnitIdentifier;
              appLovin["creative_identifier"] = adInfo.CreativeIdentifier;
              appLovin["placement"] = adInfo.Placement;
              appLovin["ad_revenue_format"] = adInfo.AdFormat;
              appLovin["ad_revenue_precision"] = adInfo.RevenuePrecision;

              var adPartners = new Dictionary<string, object>();
              adPartners["appLovin"] = appLovin;

              @event.SetAction(adInfo.NetworkName);
              @event.SetLabel(adInfo.NetworkPlacement);
              @event.SetValue(adInfo.Revenue);
              @event.AddSemanticAttribute("adPartners", adPartners);
              // AppLovin MAX has a default currency of USD
              @event.AddSemanticAttribute("currency", "USD");

              AirbridgeUnity.TrackEvent(@event);
          }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

## S2S Integration

To implement the S2S integration, you need to enter the Report Key provided by AppLovin MAX into the Airbridge dashboard.

For more detailed instructions, refer to the article below.

* [S2S Integration for AppLovin MAX (User Guide)](/en/guides/applovin-max#server-to-server-integration)

<link rel="alternate" hrefLang="en" href="https://help.airbridge.io/en/developers/applovin-max-ad-revenue-integration" />

<link rel="alternate" hrefLang="ko" href="https://help.airbridge.io/ko/developers/applovin-max-ad-revenue-integration" />
