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_100Data Attributes Method
Just add thedata-adrop-unit attribute and the SDK will automatically load the ad.
Data Attributes
Unit ID created in Ad Control Console
Context ID for Contextual Targeting
Theme setting (
light or dark) - See Dark Mode SettingsEnable 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.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
Unit ID created in Ad Control Console
User identifier (used to override SDK-level setting for individual placements)
Context ID for Contextual Targeting
Theme setting (
light or dark) - See Dark Mode SettingsEnable 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.Refreshing Ads
CallrenderAd() again to request a new ad.
Removing Ads
Callclear() to remove the ad from the container.
Ad Size
Set the container to match the size registered in the unit.| Type | Size Setting | Alignment |
|---|---|---|
| Direct Ads | Responsive support, height required | Horizontal/Vertical center |
| Backfill Ads | Initial width matching, height required | Horizontal center |
Event Handling
You can detect ad status changes and handle the UI appropriately.Supported Events
| Event | Constant | Description |
|---|---|---|
| Ad Received | AD_RECEIVED | Ad request successful |
| No Ad | AD_NO_FILL | No direct ads available |
| Request Failed | AD_FAILED | Ad request failed |
| Impression | AD_IMPRESSION | Ad impression recorded |
| Click | AD_CLICKED | User clicked the ad |
| No Backfill | AD_BACKFILL_NO_FILL | No backfill ad available |
Removing Event Listeners
Remove event listeners usingoff() when no longer needed.
AdData
Ad data passed to event handlers. See Reference > AdData for detailed field information.Custom Click Handling
WhenuseCustomClick 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.