> ## 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.

# 트래드 플러스 (TradPlus)

<Info>
  **알립니다**

  이 기능은 현재 베타 버전으로 제공되고 있습니다. 서비스 안정화 과정에서 일부 사양이 변경될 수 있습니다.
</Info>

에어브릿지와 TradPlus를 연동해 광고로 발생한 수익과 관련한 데이터를 에어브릿지 대시보드에서 확인할 수 있습니다. 에어브릿지는 TradPlus와의 SDK 연동을 지원합니다.

## **SDK 연동하기**

아래 링크에 따라 TradPlus SDK를 설치해 주세요.

* [TradPlus 안드로이드 SDK 설치 가이드](https://docs.tradplusad.com/en/docs/tradplussdk_android_doc_v6/quick_start/interstitial)
* [TradPlus iOS SDK 설치 가이드](https://docs.tradplusad.com/en/docs/integration_ios/fast_integration_ios/fast_interstitial)
* [TradPlus 유니티 SDK 설치 가이드](https://docs.tradplusad.com/en/docs/doc_u3d/u3d_integration/setting_plugin)

### 에어브릿지로 광고 수익 데이터 전송하기

TradPlus에서 발생한 광고 수익 데이터를 에어브릿지로 전송합니다. 먼저 TradPlus SDK에 광고 수익 데이터 콜백을 설정합니다. 해당 콜백을 활용해 광고 수익 데이터를 에어브릿지 SDK로 전송합니다.

<AccordionGroup>
  <Accordion title="SDK 연동하기 (Android)">
    #### Android SDK

    <CodeGroup>
      ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      TradPlusSdk.setGlobalImpressionListener { tpAdInfo ->
          if (tpAdInfo != null) {
              val adPlatform = "TradPlus"
              val adNetwork = tpAdInfo.adSourceName
              val adUnit = tpAdInfo.tpAdUnitId
              val adFormat = tpAdInfo.format
              val currency = "USD"
              val revenue = tpAdInfo.ecpm.toDouble() / 1000

              Airbridge.trackEvent(
                  AirbridgeCategory.AD_IMPRESSION,
                  mapOf(
                      AirbridgeAttribute.ACTION to adNetwork,
                      AirbridgeAttribute.LABEL to adFormat,
                      AirbridgeAttribute.VALUE to revenue,
                      AirbridgeAttribute.AD_PARTNERS to mapOf(
                          "tradPlus" to mapOf(
                              "ad_platform" to adPlatform,
                              "ad_network" to adNetwork,
                              "ad_unit" to adUnit,
                              "ad_format" to adFormat,
                              "value" to revenue
                          )
                      ),
                      AirbridgeAttribute.CURRENCY to currency
                  )
              )
          }
      }
      ```

      ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      TradPlusSdk.setGlobalImpressionListener(new GlobalImpressionManager.GlobalImpressionListener() {
          @Override
          public void onImpressionSuccess(TPAdInfo tpAdInfo) {

              if (tpAdInfo != null) {
                  String adPlatform = "TradPlus";
                  String adNetwork = tpAdInfo.adSourceName;
                  String adUnit = tpAdInfo.tpAdUnitId;
                  String adFormat = tpAdInfo.format;
                  String currency = "USD";
                  double revenue = Double.parseDouble(tpAdInfo.ecpm) / 1000;

                  Airbridge.trackEvent(
                      AirbridgeCategory.AD_IMPRESSION,
                      new HashMap() {{
                          put(AirbridgeAttribute.ACTION, adNetwork);
                          put(AirbridgeAttribute.LABEL, adFormat);
                          put(AirbridgeAttribute.VALUE, revenue);
                          put(AirbridgeAttribute.AD_PARTNERS, new HashMap() {{
                              put("tradPlus", new HashMap() {{
                                  put("ad_platform", adPlatform);
                                  put("ad_network", adNetwork);
                                  put("ad_unit", adUnit);
                                  put("ad_format", adFormat);
                                  put("value", revenue);
                              }});
                          }});
                          put(AirbridgeAttribute.CURRENCY, currency);
                      }}
                  );
              }
          }
      });
      ```
    </CodeGroup>

    #### Android SDK (Deprecated)

    <CodeGroup>
      ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      TradPlusSdk.setGlobalImpressionListener { tpAdInfo ->
          if (tpAdInfo != null) {
              val adPlatform = "TradPlus"
              val adNetwork = tpAdInfo.adSourceName
              val adUnit = tpAdInfo.tpAdUnitId
              val adFormat = tpAdInfo.format
              val currency = "USD"
              val revenue = tpAdInfo.ecpm.toDouble() / 1000

              val event = Event("airbridge.adImpression")

              val tradPlus = mutableMapOf<String, Any?>()
              tradPlus["ad_platform"] = adPlatform
              tradPlus["ad_network"] = adNetwork
              tradPlus["ad_unit"] = adUnit
              tradPlus["ad_format"] = adFormat
              tradPlus["value"] = revenue

              val adPartners = mapOf("tradPlus" to tradPlus)
              event.action = adNetwork
              event.label = adFormat
              event.value = revenue
              event.semanticAttributes = mutableMapOf(
                  "adPartners" to adPartners,
                  "currency" to currency
              )

              Airbridge.trackEvent(event)
          }
      }
      ```

      ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      TradPlusSdk.setGlobalImpressionListener(new GlobalImpressionManager.GlobalImpressionListener() {
          @Override
          public void onImpressionSuccess(TPAdInfo tpAdInfo) {

              if (tpAdInfo != null) {
                  String adPlatform = "TradPlus";
                  String adNetwork = tpAdInfo.adSourceName;
                  String adUnit = tpAdInfo.tpAdUnitId;
                  String adFormat = tpAdInfo.format;
                  String currency = "USD";
                  double revenue = Double.parseDouble(tpAdInfo.ecpm) / 1000;

                  Event event = new Event("airbridge.adImpression");

                  Map<String, Object> tradPlus = new HashMap<>();
                  tradPlus.put("ad_platform", adPlatform);
                  tradPlus.put("ad_network", adNetwork);
                  tradPlus.put("ad_unit", adUnit);
                  tradPlus.put("ad_format", adFormat);
                  tradPlus.put("value", revenue);

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

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

                  event.setAction(adNetwork);
                  event.setLabel(adFormat);
                  event.setValue(revenue);
                  event.setSemanticAttributes(semanticAttributes);

                  Airbridge.trackEvent(event);
              }
          }
      });
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="SDK 연동하기 (iOS)">
    #### iOS SDK

    <CodeGroup>
      ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      let adPlatform = "TradPlus"
      guard let adNetwork = adInfo["adNetworkName"] as? String else { return }
      guard let adUnit = adInfo["adunit_id"] as? String else { return }
      guard let adFormat = adInfo["adType"] as? String else { return }
      let currency = "USD"

      guard let ecpm = adInfo["ecpm"] as? String else { return }
      let revenue = NSNumber(value: (Float(ecpm) ?? 0) / 1000.0)

      Airbridge.trackEvent(
          category: AirbridgeCategory.AD_IMPRESSION,
          semanticAttributes: [
              AirbridgeAttribute.ACTION: adNetwork,
              AirbridgeAttribute.LABEL: adFormat,
              AirbridgeAttribute.VALUE: revenue,
              AirbridgeAttribute.AD_PARTNERS: [
                  "tradPlus": [
                      "ad_platform": adPlatform,
                      "ad_network": adNetwork,
                      "ad_unit": adUnit,
                      "ad_format": adFormat,
                      "value": revenue
                  ]
              ],
              AirbridgeAttribute.CURRENCY: currency
          ]
      )
      ```

      ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      - (void)tradPlusAdImpression:(NSDictionary *)adInfo
      {
          NSString* adPlatform = @"TradPlus";
          NSString* adNetwork = adInfo[@"adNetworkName"];
          NSString* adUnit = adInfo[@"adunit_id"];
          NSString* adFormat = adInfo[@"adType"];
          NSString* currency = @"USD";
          NSNumber *revenue = [NSNumber numberWithFloat: [adInfo[@"ecpm"] floatValue]/1000.0];
          
          [Airbridge trackEventWithCategory:AirbridgeCategory.AD_IMPRESSION semanticAttributes:@{
              AirbridgeAttribute.ACTION: adNetwork,
              AirbridgeAttribute.LABEL: adFormat,
              AirbridgeAttribute.VALUE: revenue,
              AirbridgeAttribute.AD_PARTNERS: @{
                  @"tradPlus": @{
                      @"ad_platform": adPlatform,
                      @"ad_network": adNetwork,
                      @"ad_unit": adUnit,
                      @"ad_format": adFormat,
                      @"value": revenue
                  }
              },
              @"currency": currency
          }];
      }
      ```
    </CodeGroup>

    #### iOS SDK (Deprecated)

    <CodeGroup>
      ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      let adPlatform = "TradPlus"
      guard let adNetwork = adInfo["adNetworkName"] as? String else { return }
      guard let adUnit = adInfo["adunit_id"] as? String else { return }
      guard let adFormat = adInfo["adType"] as? String else { return }
      let currency = "USD"

      guard let ecpm = adInfo["ecpm"] as? String else { return }
      let revenue = NSNumber(value: (Float(ecpm) ?? 0) / 1000.0)

      let event = ABInAppEvent()

      event?.setCategory("airbridge.adImpression")
      event?.setAction(adNetwork)
      event?.setLabel(adFormat)
      event?.setValue(revenue)
      event?.setSemantics([
          "adPartners": [
              "tradPlus": [
                  "ad_platform": adPlatform,
                  "ad_network": adNetwork,
                  "ad_unit": adUnit,
                  "ad_format": adFormat,
                  "value": revenue
              ]
          ],
          "currency": currency
      ])

      event?.send()
      ```

      ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      - (void)tradPlusAdImpression:(NSDictionary *)adInfo
      {
          NSString* adPlatform = @"TradPlus";
          NSString* adNetwork = adInfo[@"adNetworkName"];
          NSString* adUnit = adInfo[@"adunit_id"];
          NSString* adFormat = adInfo[@"adType"];
          NSString* currency = @"USD";
          NSNumber *revenue = [NSNumber numberWithFloat: [adInfo[@"ecpm"] floatValue]/1000.0];
          
          ABInAppEvent* event = [[ABInAppEvent alloc] init];
          [event setCategory:@"airbridge.adImpression"];
          [event setAction:adNetwork];
          [event setLabel:adFormat];
          [event setValue:revenue];
          [event setSemantics:@{
              @"adPartners": @{
                  @"tradPlus": @{
                      @"ad_platform": adPlatform,
                      @"ad_network": adNetwork,
                      @"ad_unit": adUnit,
                      @"ad_format": adFormat,
                      @"value": revenue
                  }
              },
              @"currency": currency
          }];

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

  <Accordion title="SDK 연동하기 (Unity)">
    #### Unity SDK

    <CodeGroup>
      ```c# C# lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      TradplusAds.Instance().AddGlobalAdImpression(OnGlobalAdImpression);

      // ...

      void OnGlobalAdImpression(Dictionary<string, object> adInfo)
      {
          string adPlatform = "TradPlus";
          var adNetwork = "";
          var adUnit = "";
          var adFormat = "";
      #if UNITY_IOS
          adNetwork = adInfo["adNetworkName"] as string;
          adUnit = adInfo["adunit_id"] as string;
          adFormat = adInfo["adType"] as string;
      #else
          adNetwork = adInfo["adSourceName"] as string;
          adUnit = adInfo["tpAdUnitId"] as string;
          adFormat = adInfo["format"] as string;
      #endif
          var currency = "USD";
          var revenue = double.Parse(adInfo["ecpm"] as string, System.Globalization.CultureInfo.InvariantCulture) / 1000;

          Airbridge.TrackEvent(
              category: AirbridgeCategory.AD_IMPRESSION,
              semanticAttributes: new Dictionary<string, object>()
              {
                  { AirbridgeAttribute.ACTION, adUnit },
                  { AirbridgeAttribute.LABEL, adFormat },
                  { AirbridgeAttribute.VALUE, revenue },
                  {
                      AirbridgeAttribute.AD_PARTNERS, new Dictionary<string, object>()
                      {
                          {
                              "tradPlus", new Dictionary<string, object>()
                              {
                                  { "ad_platform", adPlatform },
                                  { "ad_network", adNetwork },
                                  { "ad_unit", adUnit },
                                  { "ad_format", adFormat },
                                  { "value", revenue },
                              }
                          }
                      }
                  },
                  { AirbridgeAttribute.CURRENCY, currency }
              }
          );
      }
      ```
    </CodeGroup>

    #### Unity SDK (Deprecated)

    <CodeGroup>
      ```c# C# lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
      TradplusAds.Instance().AddGlobalAdImpression(OnGlobalAdImpression);

      // ...

      void OnGlobalAdImpression(Dictionary<string, object> adInfo)
      {
          string adPlatform = "TradPlus";
          var adNetwork = "";
          var adUnit = "";
          var adFormat = "";
      #if UNITY_IOS
          adNetwork = adInfo["adNetworkName"] as string;
          adUnit = adInfo["adunit_id"] as string;
          adFormat = adInfo["adType"] as string;
      #else
          adNetwork = adInfo["adSourceName"] as string;
          adUnit = adInfo["tpAdUnitId"] as string;
          adFormat = adInfo["format"] as string;
      #endif
          var currency = "USD";
          var revenue = double.Parse(adInfo["ecpm"] as string, System.Globalization.CultureInfo.InvariantCulture) / 1000;
              
          AirbridgeEvent @event = new AirbridgeEvent("airbridge.adImpression");

          var tradPlus = new Dictionary<string, object>();
          tradPlus["ad_platform"] = adPlatform;
          tradPlus["ad_network"] = adNetwork;
          tradPlus["ad_unit"] = adUnit;
          tradPlus["ad_format"] = adFormat;
          tradPlus["value"] = revenue;

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

          @event.SetAction(adUnit);
          @event.SetLabel(adFormat);
          @event.SetValue(revenue);
          @event.AddSemanticAttribute("adPartners", adPartners);
          @event.AddSemanticAttribute("currency", currency);

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

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

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