Skip to content

Commit

Permalink
add condition to detect front type and determine asPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
dskamiotis committed Nov 29, 2024
1 parent e70d935 commit ad9a9d0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib/header-bidding/a9/a9.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,32 @@ let requestQueue = Promise.resolve();

const bidderTimeout = 1500;

const displayAd = (adPosition: string): void => {
const adSlot = document.getElementById(`dfp-ad--${adPosition}`);
if (adSlot) {
window.googletag.display(adSlot.id);
}
};

const initialise = (): void => {
if (!initialised && window.apstag) {
initialised = true;
const pageConfig = window.guardian.config.page;
let adPosition = '';

if (pageConfig.isFront) {
if (pageConfig.section === 'network') {
adPosition = 'inline1';
} else {
adPosition = 'top-above-nav';
}
}
window.apstag.init({
pubID: window.guardian.config.page.a9PublisherId,
adServer: 'googletag',
bidTimeout: bidderTimeout,
});
displayAd(adPosition);
}
};

Expand Down

0 comments on commit ad9a9d0

Please sign in to comment.