Page Summary
-
Long waterfall mediation chains can increase ad request latency for critical first impressions.
-
This guide provides steps to reduce first impression latency, including setting an initialization timeout, removing waterfall ad sources from your first request, and improving performance on less time-sensitive impressions.
-
Setting an initialization timeout prevents exceeding a defined time limit for initialization before proceeding with an ad request.
-
Removing waterfall ad sources on your first request by implementing key-value segmentation can deliver ads with less latency.
-
Ad preloading with an ad request not targeting the bidding-only mediation group can improve performance on less time-sensitive impressions.
Initializing an app with long waterfall mediation chains and multiple third party adapters can increase ad request latency for critical impressions that show first in the user's session. This increased first impression latency can prevent the ad from showing as the ad request has not yet returned a response.
This guide covers the following to reduce first impression latency in your app sessions:
- Set an initialization timeout
- Remove waterfall ad sources from your first request
- Improve performance on less time-sensitive impressions
Before you begin
Before you continue, set up Google Mobile Ads SDK.
Set an initialization timeout
To avoid missing an impression opportunity, set an initialization timeout. This approach prevents your app from exceeding the time limit you defined. You can proceed with the ad request after the time limit you set, or after initialization completes.
To set a timeout and have precise control over the exact adapters you initialize, see Use configurable adapter initialization.
The following example creates an adapter initialization configuration and sets an initialization timeout of five seconds:
Swift
let adapterConfig = MediationInitializationConfiguration()
adapterConfig.includedAdFormats = [AdFormat.appOpen.rawValue as NSNumber]
adapterConfig.initializationTimeout = 5.0
Objective-C
GADMediationInitializationConfiguration *adapterConfig =
[[GADMediationInitializationConfiguration alloc] init];
adapterConfig.includedAdFormats = [NSSet setWithArray:@[ @(GADAdFormatAppOpen) ]];
adapterConfig.initializationTimeout = 5.0;
For more information, see Use configurable adapter initialization.
Remove waterfall ad sources on your first request
To deliver ads without any additional latency from waterfall ad sources, implement key-value segmentation to remove waterfall ad sources on your first ad request. Complete the following steps:
- Create a mediation group and add bidding ad sources.
- Add key-value segmentation to
your new bidding-only mediation group using key
latencyand valuelow. - Prioritize your new bidding-only mediation group above your primary mediation group in the UI. To adjust the order, change mediation group priority.
In your first ad request, include the custom targeting key-value pair:
Swift
let customTargeting: [String: String] = ["latency": "low"] let request = Request() request.customTargeting = customTargetingObjective-C
NSDictionary *customTargeting = @{@"latency" : @"low"}; GADRequest *request = [GADRequest request]; request.customTargeting = customTargeting;Test the key-value segmentation setup to verify you are correctly targeting the new bidding-only mediation group.
Improve performance on less time-sensitive impressions
To improve performance on less time-sensitive impressions, such as ads that don't need to show right at app launch, use ad preloading with an ad request that does not target the bidding-only mediation group.