Native Teasers: Batched In-Feed Ads

Fetch several native teasers in one batch and render them as entries in your content feed with dlApi.fetchNativeTeasers

Native Teasers: Batched In-Feed Ads

dlApi.fetchNativeTeasers fetches native ads for several consecutive feed positions in a single batch and returns them as feed entries, so you can inject them into a feed alongside the rest of your content.

This method does not render anything into the page. It hands you the data and leaves rendering, feed injection, and event tracking to the page.

The promise resolves with an object holding an entries array — one entry per filled position, ready to merge into your feed. Each entry carries its own adm, which you pass to dlApi.registerBidResponse for impression and viewability tracking.

Use it when the page owns the rendering (for example a homepage feed built server-side or in a framework) and you only need the ad payload.

Live Demo

See it working: Content Commerce Teasers Demo

The demo fetches live teasers from the ad server and renders them as feed entries. View the source to see the full fetchNativeTeasers → registerBidResponse flow.

Integration

Step 1: Fetch the teasers

dlApi.cmd.push(function(dlApi) {
  dlApi.fetchNativeTeasers({
    slot: 'flat-natleft3',
    limit: 3,
  }).then(function(response) {
    var teasers = response.entries;
    // ... Steps 2 and 3
  });
});

slot is required — the promise rejects when it is missing. Teaser campaigns are targeted through the slot and the per-position opts.

Step 2: Inject the entries into your feed

response.entries contains one entry per filled position. Merge them into your feed and render them the same way you render your other entries. Render each teaser into a container you can locate again in Step 3

Empty positions are excluded from entries (see Empty Positions).

Step 3: Track impressions, viewability, and clicks

For each entry, register its adm on the container you rendered the entry into. This fires the impression and, when the creative is eligible, sets up viewability (Active View) tracking:

teasers.forEach(function(entry) {
  var container = document.getElementById('feed-entry-' + entry.uuid); // the element you rendered this entry into
  dlApi.registerBidResponse(entry.adm, container);
});

Viewability is only set up when a container element is provided and the creative is marked viewable (adserver_meta.viewability === true). Without a container the impression still fires, but Active View is skipped.

Clicks are not covered by registerBidResponse — set the tile's anchor href to link.href and the click is counted by the redirect.

teasers.forEach(function(entry) {
  tileLink.setAttribute('href', entry.link.href); // the anchor of the tile you rendered this entry into
});

Options

OptionTypeDefaultDescription
slotstring– (required)Slot name used for every position.
limitnumber1Number of teaser positions to fetch (pos 1..limit).
optsobject–Targeting options merged into each position's opts. The SDK adds pos per position.

Return Value

The promise resolves with { entries }. entries holds one entry per filled position, in order, each populated from the teaser creative:

FieldDescription
uuidEntry identifier — carries the ad id.
type.codeStory kind for the renderer; defaults to article.
title.textTeaser headline.
title.prefixDisclosure text configured on the creative;
title.labelMarks the entry as sponsoring for the renderer.
image.urlTeaser image URL.
image.size.widthTeaser image width in pixels; present only when the creative carries the image size.
image.size.heightTeaser image height in pixels; present only when the creative carries the image size.
link.hrefThe tile's single link — set it as the anchor href (see Step 3). Whenever the ad carries a click-count endpoint, this is the ready-made click-counting URL (meta.adclick + destination) so the click is counted by the redirect; otherwise it's the plain destination URL.
summary.textLead text with HTML stripped; present only when the teaser has a lead.
sourcesPartner logo; present only when the teaser carries one.
flagsMarks the entry as content_commerce.
admRaw ad data (fields, meta, gctx, lctx) — pass it to registerBidResponse for impression and viewability (see Step 3).

Empty Positions

When a position returns no ad (or fails), it is skipped. If fewer ads come back than requested, entries is simply shorter than limit.

The consumer decides how to fill the gap.

SDK Methods Used

  • dlApi.fetchNativeTeasers() — fetch the batch, get the teaser entries
  • dlApi.registerBidResponse() — count impression and set up viewability per rendered teaser