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.
[null,null,["Last updated 2023-12-05 UTC."],[[["\u003cp\u003e\u003ccode\u003eadConfig()\u003c/code\u003e 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.\u003c/p\u003e\n"],["\u003cp\u003eThe 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.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can specify whether the game has sound enabled using the \u003ccode\u003esound\u003c/code\u003e parameter and control ad preloading behavior with \u003ccode\u003epreloadAdBreaks\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAn optional \u003ccode\u003eonReady\u003c/code\u003e callback can be provided to notify the game when the API is initialized and ad preloading is complete, if requested.\u003c/p\u003e\n"]]],["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"],null,["# adConfig\n\nThe **adConfig()** call communicates the game's current configuration to the\nAd Placement API. The Ad Placement API can use this to tune the way it preloads\nads and to filter the kinds of ads it requests so they're suitable (eg. video\nads that require sound).\n\nFunction signature: \n\n adConfig({\n preloadAdBreaks: 'on|auto', // Ad preloading strategy\n sound: 'on|off' // This game has sound\n onReady: () =\u003e {}, // Called when API has initialised and adBreak() is ready\n });\n\nadConfig parameters\n-------------------\n\n| Name | Type | Description |\n|-------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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. |\n| `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. |\n| `onReady` | string | **(OPTIONAL)** Called when the API has initialized and has finished preloading ads (if you requested preloading using the `preloadAdBreaks` above). |"]]