adConfig
Stay organized with collections
Save and categorize content based on your preferences.
The adConfig() call communicates the game's current configuration to the
Ad Placement API. The Ad Placement API can use this to tune the way it preloads
ads and to filter the kinds of ads it requests so they're suitable (eg. video
ads that require sound).
Function signature:
adConfig({
preloadAdBreaks: 'on|auto', // Ad preloading strategy
sound: 'on|off' // This game has sound
onReady: () => {}, // Called when API has initialised and adBreak() is ready
});
adConfig parameters
Name |
Type |
Description |
sound |
string |
(OPTIONAL) Whether the game is currently playing sound. Values: - on (default) - off This call specifies whether your game is capable of sound, and whether the sound was enabled (ie unmuted) before the call to adBreak() . This helps the Ad Placement API to select the right kind of ad for your game. Call this function as soon as the sound state of your game changes, as the Ad Placement API may have to request new creatives, and this gives it the maximum amount of time to do so.
The default value is sound on. So most games will need to make a call to adConfig() when they start to declare that they have sound enabled. |
preloadAdBreaks |
string |
(OPTIONAL) Whether ads should always be preloaded before the first call to adBreak() . Values: - on - auto (default)
The default value of auto leaves the decision up to the Ad Placement API. preloadAdBreaks can be set only once with adConfig() , and further values passed to preloadAdBreaks have no effect. Setting preloadAdBreaks after the first call to adBreak() has no effect. |
onReady |
string |
(OPTIONAL) Called when the API has initialized and has finished preloading ads (if you requested preloading using the preloadAdBreaks above). |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-12-05 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-12-05 UTC."],[[["`adConfig()` is used to inform the Ad Placement API about the game's settings, such as sound and ad preloading preferences, for better ad selection and delivery."],["The API uses this information to optimize ad preloading and ensure ads are suitable for the game's context, like avoiding sound-based ads in silent games."],["Developers can specify whether the game has sound enabled using the `sound` parameter and control ad preloading behavior with `preloadAdBreaks`."],["An optional `onReady` callback can be provided to notify the game when the API is initialized and ad preloading is complete, if requested."]]],["The `adConfig()` function communicates the game's settings to the Ad Placement API. It accepts parameters to configure ad behavior: `sound` (specifying if sound is 'on' or 'off'), `preloadAdBreaks` ('on' or 'auto' for preloading ads), and `onReady` (a callback after initialization). `sound` informs the API of the game's sound capability and status, influencing ad selection. `preloadAdBreaks` dictates ad preloading strategy, set only once.\n"]]