Skip to main content

Ad Frequency Control

Ad frequency control (AFC) limits how often viewers see ads. With AFC, you set a simple rule: after a viewer has watched an ad break, no more ads play until they've watched a set amount of content.

Why use AFC​

AFC helps you balance ad revenue with viewer experience. Use it when you want to:

  • Avoid showing back-to-back ad breaks to the same viewer.
  • Give viewers an ad-free stretch of content after they've seen ads.
  • Tune ad pressure with a few settings, without changing your ad schedule.

AFC applies to Google IMA (CSAI & SSAI) and AWS MediaTailor.

Configure AFC​

AdFrequencyControlConfiguration enables AFC and defines its thresholds. The following table lists the default values. Set enable to true to enforce AFC.

PropertyDefaultDescription
enablefalseTurns AFC on. When false, all ad opportunities play.
minimumContentConsumptionMs180_000L (3 minutes)Amount of content, in milliseconds, the viewer must watch after a qualified ad break before the next one can play.
adBreakExposureThreshold0.66Fraction of an ad break the viewer must watch for it to count as seen. 0.66 means 66%.
allowFirstOpportunitytrueAlways allows the first ad opportunity, such as the preroll, to play.

Create a configuration and pass it to a supported ads player:

val adFrequencyControl = AdFrequencyControlConfiguration(
enable = true,
minimumContentConsumptionMs = 180_000L,
adBreakExposureThreshold = 0.66,
allowFirstOpportunity = true
)

Use AFC with IMA CSAI or SSAI​

Pass a CSAIAdsRequest or SSAIAdsRequest to the matching IMAAdsPlayerFactory.imaAdComposedPlayerWith overload with the AFC configuration.

val player = IMAAdsPlayerFactory.imaAdComposedPlayerWith(
contentPlayer = contentPlayer,
adRequest = adRequest,
adFrequencyControl = adFrequencyControl
)

Use AFC with IMA DAI​

Configure IMADaiAdsPlayerBuilder with AFC. This builder doesn't have a sessionURL() method, so pass the SSAI ads request and session configuration to build().

val result = IMADaiAdsPlayerBuilder()
.mediaURL(contentUrl)
.mediaType(MediaType.DASH)
.adFrequencyControl(adFrequencyControl)
.build(
platformContext = platformContext,
adsRequest = adsRequest,
imaDaiSessionConfig = imaDaiSessionConfig
)

adsRequest must be an SSAIAdsRequest. Set imaDaiSessionConfig to an IMADaiSessionConfig.PerSession or IMADaiSessionConfig.Reuse configuration.

Use AFC with MediaTailor​

The MediaTailorAdsPlayerBuilder supports AFC with either a QpSessionConfiguration or a DzSessionConfiguration. Select the mode with sessionConfiguration, then build the player asynchronously:

val result = MediaTailorAdsPlayerBuilder()
.sessionURL(sessionUrl)
.contentURL(contentUrl)
.sessionConfiguration(sessionConfig)
.adFrequencyControl(adFrequencyControl)
.buildAsync(
platformContext = platformContext,
isVODPlayback = isVod
)

Evaluate an ad opportunity in your app​

For SSAI, the ad decision can happen before the player exists, for example during content authorization. In that case, call AdFrequencyControl.evaluateOpportunity() to ask AFC whether an ad opportunity is currently allowed. It returns true if the opportunity is allowed or false if AFC suppresses it. When AFC is disabled, it returns true.

Use the result for whatever your app needs. For example, you can skip an SSAI preroll request, tag the session, or write a log entry.

if (AdFrequencyControl.evaluateOpportunity()) {
// The opportunity is allowed. For example, request the SSAI preroll.
} else {
// The opportunity is suppressed. For example, skip the request or log it.
}

Ad suppression event​

When AFC blocks an ad opportunity, the player emits the AD_SKIPPED_AFC_POLICY ad tracking event. Use this event to identify ads skipped because of AFC policy, and report it to analytics for tracking and downstream analysis.

AFC at a glance​

The following example uses the default settings:

  1. A viewer starts a video. AFC allows the first ad opportunity, so the preroll plays.
  2. The viewer watches at least 66% of the ad break. AFC counts this as a qualified ad impression.
  3. For the next 3 minutes of content, AFC skips any scheduled ad break. The viewer watches without interruption.
  4. After the viewer has watched 3 minutes of content, the next ad break plays.

If the viewer leaves or skips an ad break before reaching 66%, AFC doesn't count it as seen. The next ad break plays as scheduled.

How AFC applies to each playback type​

AFC remembers what a viewer has watched, and it keeps that memory when the viewer moves from one video to the next. For example, a viewer who finishes an ad break at the end of one episode doesn't get another ad right at the start of the next episode. AFC does this by keeping a single, shared record of ad exposure and content watched across playback sessions.

How AFC uses that record depends on the playback type:

Playback typeWhat AFC does
VODTracks viewing and decides. AFC allows or suppresses each ad break based on the viewer's history.
LIVETracks viewing only. Ads are stitched into the stream dynamically, so AFC doesn't suppress them.

The tracked data from all types feeds the same record. For example, an ad break that plays through LIVE still counts toward the viewer's exposure. A later VOD uses that record to decide whether to play ad or not.