Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

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.setGoogletagAdSlotElementIds() api function needs be called as a part of AdEngine's functional configuration. Alternatively it can be added using declarative configuration.

Syntax

function adngin.cmd.setGoogletagAdSlotElementIds(parameter, callback)

argument name

type

optional

value

description

parameter

Array<string>

Array holding the placement names for the external ad units created through the function googletag.defineSlot().

callback

function

✔️

function(result:CallbackResult, success:boolean)

The callback function that is called with the function call result.

CallbackResult

JSON object containing the function call result, which is passed to the provided callback function in order to execute some specific action upon the function call. The object structure is as follows:

CallbackResult = {
  message: "<string holding a debug log of the function call result>",
  data: <Array holding the slot element ids for the added units>
}

The callback function will receive the above object as the first parameter and a boolean value translating the function call success status as the second parameter.

Description

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 no extra code required to to manually call the ad server for the additional GPT ads.

Scope

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

Example GPT ad slots:

  • "outstream", placement "div-gpt-outstream"

  • "sidebar", placement "div-gpt-sidebar"

<script data-cfasync="false" type="text/javascript">
  window.addEventListener("adnginLoaderReady", function() {
    // Create the external ad-units
    googletag.cmd.push(function() {
      googletag.defineSlot('/12345678/outstream', [[1, 1]], 'div-gpt-outstream').addService(googletag.pubads());
      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.setGoogletagAdSlotElementIds(['div-gpt-outstream', 'div-gpt-sidebar']);
      adngin.cmd.startAuction();
    });
  });
</script>
<script data-cfasync="false" async src="https://cdn.snigelweb.com/adengine/**site.domain**/loader.js" type="text/javascript"></script>

  • No labels