Table of Contents | ||||
---|---|---|---|---|
|
Functionality
AdEngine supports additional ad units in the page, externally created through the googletag
object in GPT. These can be Ad Manager only units, a special campaign, etc., that are not directly set in AdEngine, but can be managed by AdEngine on pair with the other units.
To add these units to AdEngine, the adngin.cmd.setGoogletagAdSlots()
api API function needs to be called as a part of AdEngine's functional configuration. Alternatively, it can be added using declarative configuration.
Syntax
function adngin.cmd.setGoogletagAdSlots(parameter, callback)
argument name | type | optional | value | description |
---|---|---|---|---|
parameter | Array<googletag.Slot> | Array holding the the | ||
callback | function | ✔️ |
| The callback function that is called with the function call result. |
...
Adding GPT ad-units to AdEngine will pass them to the Google Ad Server additionally to the AdEngine ad-units during the auction process. This improves page performance by using a single request to refresh all ads. It will also simplify the page code as there is no extra code required to to manually call the ad server for the additional GPT ads.
This function uses the GPT slot objects directly, which implies that access to the created slots data is needed, which may not be the case at all timetimes. Using setGoogletagAdSlotElementIds instead is recommended, as it decouples GPT structures from AdEngine by using the GPT div element id, which makes the page code simpler and improves performance by removing dependencies.
...
The function can be called after AdEngine loader is ready and the AdEngine queue is defined, see functional configuration for more details.
Example
Adding the googletag ad unit slots "outstream" and "sidebar" to AdEngine using the command queue and event system
...
Code Block |
---|
<script data-cfasync="false" type="text/javascript"> window.addEventListener("adnginLoaderReady", function() { googletag.cmd.push(function() { // Create the external ad-units var additionalAdSlots = []; additionalAdSlots.push(googletag.defineSlot('/12345678/outstream', [[1, 1]], 'div-gpt-outstream').addService(googletag.pubads())); additionalAdSlots.push(googletag.defineSlot('/12345678/sidebar', [[300, 250], [300, 600]], 'div-gpt-sidebar').addService(googletag.pubads())); // Add the external ad-units to AdEngine and start an auction adngin.queue.push(function(){ adngin.cmd.setGoogletagAdSlots(additionalAdSlots); adngin.cmd.startAuction(); }); }); }); </script> <script data-cfasync="false" async src="https://cdn.snigelweb.com/adengine/**site.domain**/loader.js" type="text/javascript"></script>COPYscript> |