Skip to content

Direct Integration

Direct integration loads js/apps/yaleo from CDN and calls window.yaleo.start() with the necessary parameters.

The publisher adds the Yaleo script and initialization directly in their page markup.

Include the script tag on the page:

<script async src="https://cdn.adnz.co/yaleo/index.js"></script>

Call window.yaleo.start() with the placement ID and target element:

window.yaleo.start({
yaleoPlacementId: '00000000-0000-0000-0000-000000000000',
element: document.getElementById('target-element-id'),
});

The integration script is deployed as a Raw JS entry in Headertag.

  1. Assign the Yaleo Integration Script from AdConsole / Raw Scripts to the tag. The script defines the setupYaleo function:
window.setupYaleo = function setupYaleo(elementId, yaleoPlacementId) {
function onload() {
const checkElement = setInterval(
() => {
const element = document.getElementById(elementId);
if (element) {
if (element.dataset.hydrated === '0') {
return;
}
if (window.htag.api) {
window.htag.api('1').clearEffects({ tags: [`waiting-for-element:${elementId}`] });
}
element.dataset.adnzShown = '1';
element.dataset.adnzLoaded = '1';
window.yaleo.start({ element, yaleoPlacementId });
}
},
250,
);
if (window.htag.api) {
window.htag.api('1').saveEffect(
() => {
clearInterval(checkElement);
},
{ tags: [`ad:${elementId}`, `waiting-for-element:${elementId}`] },
);
}
}
window.yaleo = window.yaleo || {};
if (!window.yaleo.start) {
const script = document.createElement('script');
script.src = 'https://cdn.adnz.co/yaleo/index.js';
script.async = true;
script.defer = true;
script.onload = onload;
document.head.appendChild(script);
} else {
onload();
}
};
  1. Add a new Raw JS script that calls setupYaleo with the target element ID and placement ID:
setupYaleo('target-element-id', '00000000-0000-0000-0000-000000000000');

For publishers with complex or non-standard integration requirements, per-publisher scripts are maintained in js/scripts/yaleo/. Each script wraps the standard window.yaleo.start() call and extends it with publisher-specific logic — for example, resolving the target element dynamically, overriding the default ad index, or deferring initialization until a publisher-specific lifecycle event fires.

window.yaleo.start() accepts the following options:

ParamTypeDefaultDescription
yaleoPlacementIdstringRequired. The placement ID.
elementHTMLElementTarget element. If not provided, created next to the script tag.
debugbooleanEnables app-specific debug logging and test mode for ads.
forceMobilebooleanForces mobile placement configuration.
iframeModebooleanIndicates that the root element is an iframe child, overriding the default auto-detection. Reuses the existing iframe’s document for rendering instead of creating a new one.
iframeFullWidthbooleantrueApplies 100% width to all parent iFrame elements.
shadowDomRemovedbooleanIf true, replaces Shadow DOM with an iframe for encapsulation.
shadowDomOpenModebooleanRenders ShadowRoot in open mode.
mockRecommendationsbooleanUses mock recommendations instead of real data.
headerTagUndoEffectEnabledbooleanfalseSaves the cleanup effect to the Header Tag’s undo effect stack.
brandingTagLocationBrandingTagLocationPLACEMENT_CONTAINERWhere to display the branding tag.
urlstringOverrides the parent page URL used for targeting and analytics.
placementPlacementResponse | nullProvide the placement directly, bypassing the fetch by yaleoPlacementId.
forceXandrCreativeIdnumberForces a specific Xandr creative ID.
gdprConsentYaleoGdprConsent | nullGDPR consent data. Supports macros (e.g. ${GDPR_APPLIES}) for tag-in-tag integrations.
ParamDescription
formatArticleDateFormats article dates.
formatItemsFormats, filters, or sorts placement items — for example, always displaying an ad as the first item.
formatReadingTimeFormats article reading time.
getArticleClassNamesReturns custom class names for article elements.
getArticleUrlOverrides article URLs. Useful for mobile app deep links.
loadAdsCustomizes the ad loading logic.
ParamDescription
onXandrResponseReceivedFires when the Xandr response is received.
onElementsReadyFires when ads are loaded and DOM elements inside Shadow DOM are accessible.
onErrorFires when an error occurs.