Skip to main content

Implementation Methods

You can implement banner ads in two ways.
Use the test unit ID in development: PUBLIC_TEST_UNIT_ID_320_100

1. Data Attributes Method

The simplest method - just add the data-adrop-unit attribute and the SDK will automatically load the ad.

Data Attributes

string
required
Unit ID created in Ad Control Console
string
Context ID for Contextual Targeting
string
default:"light"
Theme setting (light or dark) - See Dark Mode Settings
boolean
default:false
Enable custom click handling - When true, SDK will not automatically navigate to the destination URL on click, only emit adClicked event with destination URL. Allows developers to implement custom click behavior.
string
default:"responsive"
Backfill ad rendering mode (responsive or fixed). See the Backfill Rendering Mode guide for details. (SDK 1.2.3+)
string
Advertising identifier — required for the View on Device feature to preview a draft creative on a registered test device. Do not hard-code in production.

Refreshing Ads

Change the React key to remount the component and request a new ad.

2. renderAd Method

Use this when you want direct control over ad loading timing.

renderAd Options

string
required
Unit ID created in Ad Control Console
string
User identifier (used to override SDK-level setting for individual placements)
string
Context ID for Contextual Targeting
string
default:"light"
Theme setting (light or dark) - See Dark Mode Settings
boolean
default:false
Enable custom click handling - When true, SDK will not automatically navigate to the destination URL on click, only emit adClicked event with destination URL. Allows developers to implement custom click behavior.
'responsive' | 'fixed'
default:"responsive"
Backfill ad rendering mode. See the Backfill Rendering Mode guide for details. (SDK 1.2.3+)
string
Advertising identifier — required for the View on Device feature to preview a draft creative on a registered test device. Do not hard-code in production.

Refreshing Ads

Call renderAd() again to request a new ad. Can also be used on placements created with Data Attributes.
When calling renderAd() on a placement created with Data Attributes, you only need to pass items that don’t exist in data attributes or items you want to modify.

Removing Ads

Call clear() to remove the ad from the container.

Ad Size

Recommended: responsive width + aspect-ratio matching the registered unit size. The slot scales with the device width and the height is locked by the ratio (no CLS).
Fixed pixel size is also supported when pixel-precise alignment is required.
For container sizing patterns and how to choose a backfill rendering mode, see the Backfill Rendering Mode guide.

Event Handling

You can detect ad status changes and handle the UI appropriately.

Supported Events

Always remove event listeners using off() when the component unmounts.

AdData

Ad data passed to event handlers. See Reference > AdData for detailed field information.

Custom Click Handling

When useCustomClick is enabled, the SDK will not automatically navigate to the destination URL. Instead, you can handle the click event and implement custom behavior.
With custom click handling enabled, you have full control over what happens when users click the ad. The destinationURL is provided in the adClicked event data.

Complete Example

BannerAd.tsx

Usage Example


Backfill Ads

When backfill ads are enabled, they are automatically requested when no direct ads are available. You can distinguish ad types using adData.format.
Development Environment Testing: If at least one ad unit connected to the app is Monetizing, backfill ad requests can be made from localhost. On unapproved domains, an AD_BACKFILL_NO_FILL event will be triggered.