var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; var googletag_ref; var PREBID_TIMEOUT = 1000; var FAILSAFE_TIMEOUT = 3000; //load the apstag.js library !function(a9,a,p,s,t,A,g){if(a[a9])return;function q(c,r){a[a9]._Q.push([c,r])}a[a9]={init:function(){q("i",arguments)},fetchBids:function(){q("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]};A=p.createElement(s);A.async=!0;A.src=t;g=p.getElementsByTagName(s)[0];g.parentNode.insertBefore(A,g)}("apstag",window,document,"script","//c.amazon-adsystem.com/aax2/apstag.js"); //initialize the apstag.js library on the page to allow bidding apstag.init({ pubID: '4d82ee98-0c5b-4c96-a74c-68b0a5395433', //enter your pub ID here as shown above, it must within quotes adServer: 'googletag', gdpr: { cmpTimeout: PREBID_TIMEOUT } }); console.log("apstag init done (with timeout)"); function printSlots() { var slots = googletag.pubads().getSlots() for (s in slots) { var slot = slots[s]; var sizes = new Array(); for (z in slot.getSizes()) { var size = slot.getSizes()[z]; sizes.push(new Array(size.l,size.j)); } console.log("Slot '" + slot.getAdUnitPath() + "' -> div '" + slot.getSlotElementId() + "' -> sizes: " + JSON.stringify(sizes)); } } function isMobile() { return (screen.width <= 1024); } function zdkFindCMP() { var curr = null; var i=0; do { try { i++; if (curr == null) curr = window; else curr = curr.parent; if (typeof curr.__tcfapi === 'function') return true; } catch(err) { console.log("zerr: "+err); } } while (curr !== window.top && i<20); //avoid infinite loop return false; } /* returns [adUnits, adsSlots] */ function aplus_buildAdUnits(googletag) { var slots = new Array(); // parse google slots definition var g_slots = googletag.pubads().getSlots() for (s in g_slots) { var slot = g_slots[s]; var sizes = new Array(); for (z in slot.getSizes()) { var size = slot.getSizes()[z]; sizes.push(new Array(size.l,size.j)); } slots.push({"slot":slot.getAdUnitPath(),"div":slot.getSlotElementId(),"sizes":sizes}); } // generate the adunits & adsSlots var adUnits = new Array(); var adsSlots = new Array(); for (s in slots) { var googleSlot = slots[s]; var aplus_slot_found = aplus_slots.filter(function(el){ return (el.slot==googleSlot.slot); }); if (!aplus_slot_found || aplus_slot_found.length<1) { console.log("slot: "+googleSlot.slot+" not matched"); continue; } var pl_id = (isMobile())?aplus_slot_found[0].plm:aplus_slot_found[0].pld; var aplus_placement_found = aplus_placements.filter(function(el){ return (el.pl==pl_id); }); if (!aplus_placement_found || aplus_placement_found.length<1) { console.log("placement: "+pl_id+" not found"); continue; } //console.log("found ["+JSON.stringify(aplus_slot_found[0])+"] -> "+JSON.stringify(aplus_placement_found[0])); adUnits.push({ code: googleSlot.slot, mediaTypes: { banner: { sizes: aplus_placement_found[0].sizes } }, bids: aplus_placement_found[0].bids }); adsSlots.push({ slotID: googleSlot.div, slotName: googleSlot.slot, sizes: aplus_placement_found[0].sizes }); } //console.log("--- slots recreated:"); //console.log(adUnits); //console.log(adsSlots); return [adUnits,adsSlots]; } // const zCallback = (tcData, success) => { //console.log("__tcfapi ST: "+tcData.eventStatus); if (success && (tcData.eventStatus === 'tcloaded' || tcData.eventStatus === 'useractioncomplete')) { console.log("__tcfapi CALL ADSERVERS"); zEngineStart(); // remove the ourself to not get called more than once __tcfapi('removeEventListener', 2, (success) => { /*if (success) { console.log("__tcfapi removeEventListener OK"); } else { console.log("__tcfapi removeEventListener NO"); }*/ }, tcData.listenerId); } else { //console.log("__tcfapi ??"); } } function zEngineStart() { // initiate bid request requestHeaderBids(); // set failsafe timeout window.setTimeout(function() { console.log("failsafe timeout"); sendAdserverRequest(); }, FAILSAFE_TIMEOUT); } // var adUnits_adsSlots; var adUnits; var adsSlots; var requestManager; // when both APS and Prebid have returned, initiate ad request function biddersBack() { console.log("biddersBack"); if (requestManager.aps && requestManager.prebid) { console.log("biddersBack - allDone!"); sendAdserverRequest(); } return; } // sends adserver request function sendAdserverRequest() { console.log("sendAdserverRequest"); if (requestManager.adserverRequestSent === true) { return; } requestManager.adserverRequestSent = true; googletag_ref.cmd.push(function() { console.log("googletag.pubads().refresh()"); googletag_ref.pubads().refresh(); }); } // sends bid request to APS and Prebid function requestHeaderBids() { console.log("requestHeaderBids()"); if (!adsSlots || adsSlots.length<1) // no needs to do anything.. no slots found return; // APS request - NOTE: fetchBids() crashes with empty slots apstag.fetchBids({ slots: adsSlots, timeout: PREBID_TIMEOUT },function(bids) { googletag_ref.cmd.push(function() { console.log("got response from aps"); apstag.setDisplayBids(); requestManager.aps = true; // signals that APS request has completed biddersBack(); // checks whether both APS and Prebid have returned }); } ); // prebid request pbjs.que.push(function() { // pbjs 2/2 (requestBids) pbjs.requestBids({ bidsBackHandler: function() { googletag_ref.cmd.push(function() { console.log("got response from prebid"); pbjs.setTargetingForGPTAsync(); requestManager.prebid = true; // signals that Prebid request has completed biddersBack(); // checks whether both APS and Prebid have returned }) }, timeout: PREBID_TIMEOUT }); }); } //called by the html page just before "googletag.enableServices()" and after googletag.defineSlot(...)s //UAM support function oz_config(googletag) { googletag_ref = googletag; googletag_ref.pubads().disableInitialLoad(); adUnits_adsSlots = aplus_buildAdUnits(googletag_ref); adUnits = adUnits_adsSlots[0]; adsSlots = adUnits_adsSlots[1]; console.log("adUnits & adsSlots:"); console.log(adUnits_adsSlots); pbjs.que.push(function() { // pbjs 1/2 (cfg) configurePBJS(); bidderSettingsPBJS(); pbjs.addAdUnits(adUnits); console.log("addAdUnits done"); }); // ***** parallel UAM ***** // config/sync object requestManager = { adserverRequestSent: false, aps: false, prebid: false }; // check whether start the engine or wait for CMP approval/refuse if (zdkFindCMP()) { console.log("__tcfapi - set listener"); __tcfapi('addEventListener', 2, zCallback); //zEngineStart() will be called after CMP approval/refusal } else { console.log("__tcfapi not found - load normally"); zEngineStart(); } } // NOCMP based on CMP in page detection + userSync iframe enabled with filters function configurePBJS() { //console.log("configuring pbjs"); /* pbjsConfig */ pbjs.setConfig({ /*userSync: { iframeEnabled: true },*/ userSync: { filterSettings: { iframe: { bidders: '*', // '*' means all bidders filter: 'include' } } }, priceGranularity: "dense", currency: { // enables currency feature "adServerCurrency": "EUR", //"granularityMultiplier": 1, // 0.50 increment up to 5 is fine for GBP... what is that?!?! // until bidder adapters are updated to define the bid currency // the system assumes bids are in USD. This can be overridden, for instance: "bidderCurrencyDefault": { "openx": "EUR" }, "conversionRateFile": "//currency.prebid.org/latest.json" // prebid's lib bug fix - this way allows both http and https }, consentManagement: { gdpr: { cmpApi: 'iab', timeout: 8000, allowAuctionWithoutConsent: true, defaultGdprScope: true } }, improvedigital: { usePrebidSizes: true }, //rubicon new config: Single-Request optimization rubicon: {singleRequest: true} }); if (!zdkFindCMP()) { // no CMP inside the publiser's page. set "NOCMP" parameters overriding consentManagement console.log("znocmp"); pbjs.setConfig({ consentManagement: { gdpr: { cmpApi: 'static', consentData: { getConsentData: { 'gdprApplies': false } } } } }); } else { console.log("zcmp"); } /* /pbjsConfig */ } function bidderSettingsPBJS() { //console.log("bidderSettings pbjs"); //ssps price adjustment pbjs.bidderSettings = { /*appnexus: { bidCpmAdjustment : function(bidCpm){ // bidCpm = bidCpm * 1.0; return bidCpm; } },*/ rubicon: { bidCpmAdjustment : function(bidCpm){ bidCpm = bidCpm * 0.90; return bidCpm; } }, /*openx: { bidCpmAdjustment : function(bidCpm){ // bidCpm = bidCpm * 1.0; return bidCpm; } },*/ adform: { bidCpmAdjustment : function(bidCpm){ bidCpm = bidCpm * 0.90; return bidCpm; } }, pubmatic: { bidCpmAdjustment : function(bidCpm){ bidCpm = bidCpm * 0.92; return bidCpm; } }, aol: { bidCpmAdjustment : function(bidCpm){ bidCpm = bidCpm * 0.89; return bidCpm; } }, adasta: { bidCpmAdjustment : function(bidCpm){ bidCpm = bidCpm * 0.7; return bidCpm; } } }; } /* this will be different for each publisher/site */ var aplus_slots = [ {slot:"/57491254/ilpost.it/consumismi/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/consumismi/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/consumismi/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/consumismi/Top",plm:90681}, {slot:"/57491254/ilpost.it/homepage/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/homepage/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/homepage/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/homepage/Top",plm:90681}, {slot:"/57491254/ilpost.it/lifestyle/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/lifestyle/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/lifestyle/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/lifestyle/Top",plm:90681}, {slot:"/57491254/ilpost.it/Meteo/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/Meteo/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/Meteo/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/Meteo/Top",plm:90681}, {slot:"/57491254/ilpost.it/news/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/news/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/news/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/news/Top",plm:90681}, {slot:"/57491254/ilpost.it/scienza/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/scienza/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/scienza/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/scienza/Top",plm:90681}, {slot:"/57491254/ilpost.it/Speciali_Minisiti/Iren_2020_Speciale/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/Speciali_Minisiti/Iren_2020_Speciale/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/Speciali_Minisiti/Iren_2020_Speciale/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/Speciali_Minisiti/Iren_2020_Speciale/Top",plm:90681}, {slot:"/57491254/ilpost.it/Speciali_Minisiti/speciale_covid19_2020/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/Speciali_Minisiti/speciale_covid19_2020/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/Speciali_Minisiti/speciale_covid19_2020/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/Speciali_Minisiti/speciale_covid19_2020/Top",plm:90681}, {slot:"/57491254/ilpost.it/sport/MaxTicker",pld:90678}, {slot:"/57491254/ilpost.it/sport/MPU_Middle",plm:90682,pld:90679}, {slot:"/57491254/ilpost.it/sport/MPU_Top",plm:90683,pld:90680}, {slot:"/57491254/ilpost.it/sport/Top",plm:90681} ]; var aplus_placements = [ {pl:90678,sizes:[[970, 250],[728, 90]],bids:[{bidder:'appnexus', params:{placementId:'19754023'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'triplelift', params:{inventoryCode:'Next14_ilpost_970x250_prebid_desktop'}},{bidder:'adform', params:{mid:'848931',rcur:'USD'}},{bidder:'onemobile', params:{dcn:'8a9690fa017171304fb3314892440075',pos:'8a9691260173736beb0c70dbaa440096'}},{bidder:'ix', params:{siteId:'657674',size:[970,250]}}]}, {pl:90682,sizes:[[300, 250],[300, 251]],bids:[{bidder:'appnexus', params:{placementId:'19754049'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'triplelift', params:{inventoryCode:'Next14_ilpost_300x250_prebid_mobile'}},{bidder:'adform', params:{mid:'848934',rcur:'USD'}},{bidder:'onemobile', params:{dcn:'8a9690fa017171304fb33148947e0077',pos:'8a9694780173736bee7070d8cc730012'}},{bidder:'ix', params:{siteId:'657679',size:[300,250]}}]}, {pl:90679,sizes:[[300, 250],[300, 251]],bids:[{bidder:'appnexus', params:{placementId:'19754030'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'triplelift', params:{inventoryCode:'Next14_ilpost_300x250_prebid_desktop'}},{bidder:'adform', params:{mid:'848930',rcur:'USD'}},{bidder:'onemobile', params:{dcn:'8a9690fa017171304fb3314892440075',pos:'8a9691260173736beb0c70dc48f10097'}},{bidder:'ix', params:{siteId:'657675',size:[300,250]}}]}, {pl:90683,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'19754051'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'triplelift', params:{inventoryCode:'Next14_ilpost_300x250_prebid_mobile_top'}},{bidder:'triplelift', params:{inventoryCode:'Next14_ilpost_300x250_prebid_mobile_top'}},{bidder:'adform', params:{mid:'848933',rcur:'USD'}},{bidder:'onemobile', params:{dcn:'8a9690fa017171304fb33148947e0077',pos:'8a9691260173736beb0c70d94f630095'}},{bidder:'ix', params:{siteId:'657680',size:[300,250]}}]}, {pl:90680,sizes:[[300, 250],[300, 600]],bids:[{bidder:'appnexus', params:{placementId:'19754036'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'triplelift', params:{inventoryCode:'Next14_ilpost_300x250_prebid_desktop_top'}},{bidder:'adform', params:{mid:'848928',rcur:'USD'}},{bidder:'onemobile', params:{dcn:'8a9690fa017171304fb3314892440075',pos:'8a9691260173736beb0c70dc91640098'}},{bidder:'ix', params:{siteId:'657677',size:[300,250]}}]}, {pl:90681,sizes:[[320, 50],[320, 100]],bids:[{bidder:'appnexus', params:{placementId:'19754044'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'triplelift', params:{inventoryCode:'Next14_IlPost_HDX_prebid'}},{bidder:'adform', params:{mid:'848936',rcur:'USD'}},{bidder:'onemobile', params:{dcn:'8a9690fa017171304fb33148947e0077',pos:'8a9691260173736beb0c70d36e490094'}},{bidder:'ix', params:{siteId:'657678',size:[320,50]}}]} ];