🧩Public API

This section documents the public API exposed by the wrapper, grouped into Data Attributes, Functions, and Events. Code snippets use the global $$PREBID_GLOBAL$$ command queue interface where applicable.

Note: $$PREBID_GLOBAL$$ is a macro placeholder for the wrapper's global object. In custom scripts within this documentation, use the macro as shown. In public environments, use the actual global variable name assigned by your integration/build.

Data Attributes

Add the following data- attributes to ad unit containers. Use single quotes around attribute values, especially when passing JSON.

Required: data-aaad and data-aa-adunit.

  • Aaad (data-aaad): Marks the element as an ad unit.

    • Values: 'true' to enable, 'false' to disable.

    • Required on all body ad unit elements.

  • Adunit (data-aa-adunit): Full GAM ad unit code path to map the element.

    • Example: '/22181265/Test_abcd' or multi-level '/22181265/Top/Child'.

    • Use the GAM Ad unit CODE, not the UI name.

    • Required.

  • Sizes (data-aa-sizes): Restrict allowed sizes for the ad unit.

    • JSON array of [width,height] pairs, e.g. '[[300,250],[300,600]]'.

  • OutOfPage (data-aa-outofpage): Marks the ad unit as out-of-page.

    • Values: 'true' or 'false'.

  • Device (data-aa-device): Restrict display by device types.

    • JSON array of strings, e.g. '["desktop","tablet"]'.

  • Targeting (data-aa-targeting): Custom GAM targeting key-values at ad unit level.

    • JSON object, e.g. '{"category":"cars","section":"auto"}'.

  • Lazy Loaded (data-aa-lazy-loaded): Enable lazy loading near viewport.

    • Values: 'true' or 'false'.

  • Refresh timed (data-aa-refresh-timed): Auto-refresh rate in seconds after render.

    • Integer as string, e.g. '60'.

  • Refresh viewable (data-aa-refresh-viewable): Auto-refresh rate in seconds after becoming viewable.

    • Integer as string, e.g. '60'.

  • Additional non hb sizes (data-aa-additional-non-h-b-sizes): Sizes sent only to GAM (excluded from HB auctions).

    • JSON array of size pairs or string "fluid", e.g. '["fluid",[1,1]]'.

Example

Functions

All function calls should be queued and executed via the global command queue $$PREBID_GLOBAL$$.cmd. Replace examples accordingly.

Refresh

  • Refresh All: Refresh all ad units on the page.

  • Refresh Adunits: Refresh by GAM ad unit codes.

  • Refresh IDs: Refresh by element IDs.

  • Refresh Elements: Refresh by element handles.

Destroy

  • Destroy All: Destroy all ad units on the page.

  • Destroy Adunits: Destroy by GAM ad unit codes.

  • Destroy IDs: Destroy by element IDs.

  • Destroy Elements: Destroy by element handles.

Dynamic Content Processing

When new ad unit DIVs are injected after page load, notify the wrapper to process them.

  • Process Ads on Page

  • Alternative (DOM Event)

Privacy Settings

Pass privacy signals for compliance frameworks.

  • Set Privacy Settings

  • Set Multiple Privacy Settings

  • Clear Privacy Setting

Wrapper Settings

Configure global wrapper behavior.

  • Set Timeout (ms)

  • Set Lazy Load Fetch Distance (px)

  • Set Lazy Load Fetch Distance in Portviews

User Info

Retrieve information about the current user. Availability is asynchronous; calling too early may return isSet: false.

  • Get User Info

Timing note: if isSet is false, listen for the updateUserInfo event to know when the data becomes available.

Globals

Global variables exposed by the wrapper.

  • isLoaded: Boolean that indicates when the wrapper has finished loading.

  • wrapperVersion: String representing the wrapper version.

Wrapper Introspection

Utility getters for wrapper state and configuration.

  • getWrapperConfig(): Returns the current wrapper configuration object.

  • getWrapperInternalAdunits(): Returns the internal list of wrapper ad units.

  • getWrapperDeviceDetection(): Returns detected device information used by the wrapper.

Events

updateUserInfo

Fired when user info becomes available or is updated. Subscribe using the standard Prebid event interface. The event payload matches the getUserInfo() return shape.

Reference: Prebid onEvent

Example: Mitigate timing with getUserInfo + updateUserInfo

Refer to your integration guide for any additional events available in your build.

Last updated