Native Ad Format

Native ads allow for the seamless integration of ad content into the native views of your application, ensuring that ads maintain the style and quality consistent with the rest of your app. The RTB-Stack SDK makes it easy to integrate and manage native ads in Unity.

1. Load and Display Native Ads

Follow these steps to load and display native ads in your application:

Import RTB-Stack SDK

First, import the SDK into your Unity class:

using Plugins.RtbStackSDK;

Load a Native Ad

To load a native ad, call the following method:

RtbStackSDK.LoadNative("ENDPOINT_REQUEST_URL", "TAG_ID", RTBStackSDK.Position.BOTTOM, RTBStackSDK.NativeTemplate.SMALL);

Details:

  • ENDPOINT_REQUEST_URL: Obtain this from the Edit Endpoint window as described in the following article.
  • TAG_ID: Use a random string value as a Tag ID for reporting purposes.

The available positions for native ads are:

  • TOP
  • CENTER
  • BOTTOM

The available templates for native ads are:

  • SMALL
  • MEDIUM

By default, the background color for native ads is white (#FFFFFF).

You can also specify a custom background color for the native ad by passing a hex code as the last parameter:

RtbStackSDK.LoadNative("ENDPOINT_REQUEST_URL", "TAG_ID", RTBStackSDK.Position.BOTTOM, RTBStackSDK.NativeTemplate.SMALL, "#000000");

2. Listen for Native Ad Events

Subscribe to native ad events to track loading, errors, and clicks:

RtbStackSDK.onNativeAdLoadedEvent += onNativeAdLoaded;
RtbStackSDK.onNativeAdFailedToLoadEvent += onNativeAdFailedToLoad;
RtbStackSDK.onNativeAdClickedEvent += onNativeAdClicked;

void onNativeAdLoaded() {
    // Handle native ad loaded
}

void onNativeAdFailedToLoad(string error) {
    // Handle native ad load failure
}

void onNativeAdClicked(string url) {
    // Handle native ad click
}

3. Destroy Native Ads

When the native ad is no longer needed, destroy it to free up resources:

RtbStackSDK.DestroyNative("TAG_ID");

4. Available Click Actions

The RTB-Stack SDK allows you to configure the click action for native ads. Use the following method to set the click action:

RtbStackSDK.SetNativeClickThroughAction("TAG_ID", RtbStackSDK.ClickThroughAction.OPEN_DEVICE_BROWSER);

The available click actions are:

  • OPEN_SDK_BROWSER
  • OPEN_DEVICE_BROWSER
  • RETURN_URL

Native Templates

The RTB-Stack SDK offers two types of native templates: Small and Medium. These templates are designed to fit seamlessly within different parts of your application.

  • Small Template: This is a long rectangular ad view typically used inside a content feed or at the bottom of a screen.
  • Medium Template: This template is also rectangular but generally larger, suitable for use inside a content feed or on a transitional screen of the app.
Updated on March 14, 2025