add ads directly to freestar queue after its initialised
This commit is contained in:
parent
d3c50366ad
commit
8575c92221
2 changed files with 22 additions and 11 deletions
|
|
@ -14,15 +14,26 @@
|
|||
const adId = getRandomAdId();
|
||||
|
||||
onMount(() => {
|
||||
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
||||
window.graphicsAdQueue.push({
|
||||
const adSlot = {
|
||||
placementName,
|
||||
slotId: adId,
|
||||
targeting: {
|
||||
div_id: adId,
|
||||
type: adType,
|
||||
},
|
||||
});
|
||||
};
|
||||
// @ts-ignore
|
||||
const freestar = window?.freestar;
|
||||
// Add adSlot to freestar queue directly if already initialised
|
||||
if (freestar) {
|
||||
freestar.queue.push(function () {
|
||||
freestar.newAdSlots([adSlot], freestar.config.channel);
|
||||
});
|
||||
// ... otherwise add to the graphicsAdQueue queue.
|
||||
} else {
|
||||
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
||||
window.graphicsAdQueue.push(adSlot);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -57,14 +57,6 @@ export const loadBootstrap = () => {
|
|||
window.googletag.pubads().collapseEmptyDivs(true);
|
||||
});
|
||||
|
||||
if (!Array.isArray((<any>window).graphicsAdQueue)) {
|
||||
console.error('Ad queue not initialized!');
|
||||
}
|
||||
|
||||
freestar.queue.push(function() {
|
||||
freestar.newAdSlots((<any>window).graphicsAdQueue || [], freestar.config.channel);
|
||||
});
|
||||
|
||||
// Set page-level key-values
|
||||
// cf: https://help.freestar.com/help/using-key-values
|
||||
freestar.queue.push(function() {
|
||||
|
|
@ -81,5 +73,13 @@ export const loadBootstrap = () => {
|
|||
window.googletag.pubads().setTargeting('template', 'graphics');
|
||||
window.googletag.pubads().setTargeting('graphicId', graphicId);
|
||||
});
|
||||
|
||||
if (!Array.isArray((<any>window).graphicsAdQueue)) {
|
||||
console.error('Ad queue not initialized!');
|
||||
}
|
||||
|
||||
freestar.queue.push(function() {
|
||||
freestar.newAdSlots((<any>window).graphicsAdQueue || [], freestar.config.channel);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue