Skip to main content

Implementation Methods

Banner ads can be easily implemented using HTML attributes only. Ads are automatically requested when the ad placement is rendered, without any function calls.
Use the test unit ID in development: PUBLIC_TEST_UNIT_ID_320_100

Data Attributes 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. 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

Create a new ad placement DOM and replace the existing DOM to request a new ad.

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.

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

Removing Event Listeners

Remove event listeners using off() when no longer needed.

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