For the complete documentation index, see llms.txt. This page is also available as Markdown.

Set up Google OOP format

Configure Google Ad Manager out-of-page slots through HB Manager auction callbacks.

Use this pattern to define selected Google Ad Manager placements as out-of-page slots.

The callback replaces googletag.defineSlot() with googletag.defineOutOfPageSlot() for matching slots.

Before you start

Add an identifying attribute to each slot that should use an out-of-page format. This example uses data-dfp-oop.

The implementation overrides the Google slot definition during onBeforeAuctionSetup.

Use this pattern only with Google Ad Manager placements.

Implementation

Register the callback before loading ads:

out-of-page-slot.js
relevantDigital.addAuctionCallbacks({
    onBeforeAuctionSetup: ({ auction }) => {
        auction.googletagCalls = auction.googletagCalls || {};
        auction.googletagCalls.defineSlot = (adUnitPath, size, div) => {
            const element = document.getElementById(div);
            const format = element?.getAttribute('data-dfp-oop');

            if (format === 'outOfPage' || format === 'homepageOutOfPage') {
                return googletag.defineOutOfPageSlot(adUnitPath, div);
            }

            return googletag.defineSlot(adUnitPath, size, div);
        };
    },
});

How it works

  1. onBeforeAuctionSetup runs before the auction starts.

  2. The callback overrides the auction’s defineSlot function.

  3. The override reads data-dfp-oop from the slot element.

  4. Matching values create an out-of-page slot. All other slots use the standard definition.

Last updated

Was this helpful?