Ads in Live Blog, Comments and Stories

Overview

Live Blog, Comments, Story and Web Story can leave empty ad slots between their items. UniSignIn doesn't serve ads itself: your ad stack fills the slots.

  • With BiddingStack on the page, the slots are filled the same way as the rest of your ads.
  • With another ad server, such as Google Ad Manager on its own, listen for the ad_slots event and fill the slots it gives you, see Use your own ad server.

Readers with an ad-free experience, and pages marked as no-ads pages, get no slots.

Choose where the slots go

Add these attributes to the widget's container:

AttributeDescription
data-ad-startA slot after this many items. For example, 3 puts the first slot after the 3rd item.
data-ad-intervalThen a slot every this many items. For example, 5 adds a slot every 5 items after the first one. Required for Live Blog; for the other widgets, leave it out for a single slot.

For example, a slot after the 3rd comment, then after every 5 more:

<div data-exp="unis-comment" data-exp-id="EXPERIENCE_ID" data-ad-start="3" data-ad-interval="5"></div>
WidgetSlots goWithout the attributes
Live Blogbetween postsno slots
Commentsbetween comments, under each top-level commentno slots
Storybetween cards in the rowthe experience's Ad slot setting
Web Storybetween stories in the playerthe experience's Ad slot setting

Use BiddingStack

Each slot is an empty <div> with a class for its widget and data-ad-slot set to its number:

WidgetSlot class
Live Blogunis-liveblog-ai-mpu
Commentsunis-comment-ai-mpu
Storyunis-story-mpu
Web Storyunis-webstory-mpu

Ask your BiddingStack contact to set up an ad unit for each class you use. Whenever new slots appear, for example when a reader loads more comments, the widget asks BiddingStack to fill them.

Use your own ad server

Whenever new slots appear, the widget sends an ad_slots event with the new slot elements. Each slot is sent once, so loading more posts or comments only sends the slots that were added. The event waits until your page listens for it, so your script can load after the widgets.

window.unisignin = window.unisignin || {}
window.unisignin.cmd = window.unisignin.cmd || []
window.unisignin.cmd.push(['register_event', 'ad_slots', function (event) {
  // event.widget: 'liveblog', 'comment', 'story' or 'webstory'
  // event.slots: the new slot elements
  event.slots.forEach(function (slot) {
    // fill the slot with your ad server
  })
}])

For example, with Google Ad Manager. Give each slot an ID first, as Google Ad Manager needs one:

var unisAdCount = 0
window.unisignin.cmd.push(['register_event', 'ad_slots', function (event) {
  event.slots.forEach(function (slot) {
    if (!slot.id) slot.id = 'unis-ad-' + ++unisAdCount
    googletag.cmd.push(function () {
      googletag.defineSlot('/1234567/in_feed', [300, 250], slot.id).addService(googletag.pubads())
      googletag.display(slot.id)
    })
  })
}])

Replace /1234567/in_feed and the size with your own ad unit. If BiddingStack is also on the page, it is still asked to fill the slots, so fill only the slots BiddingStack doesn't.

Stay ahead in first-party data

Identity, consent, audience, and subscription insights for publishers. A few emails a month, no spam.

By subscribing you agree to our privacy policy.