var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; var googletag_ref; var PREBID_TIMEOUT = 2000; var FAILSAFE_TIMEOUT = 3000; // UAM vars // 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' ,schain: { complete: 1, ver: '1.0', nodes: [ { "asi":"next14.com", "sid":"23598", "hp":1 } ] } }); var adsSlots; 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 zdk_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 = (zdk_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) => {}, tcData.listenerId); } else { //console.log("__tcfapi ??"); } } // ***** parallel UAM+criteo+pbjs ***** // config/sync object window.hb_status = { n_adserver_callback: [], adserverRequestSent: false, // true once everything has been completed prebidTargetingSet: false }; //if i don't have criteo / uam integration, just set them already done window.hb_status.n_adserver_callback.push("criteo"); function zEngineStart() { pbjs.que.push(function() { console.log("on pbjs PUSH request bids"); // // ===== APS request console.log("===== set aps(UAM) callback"); apstag.fetchBids({ slots: adsSlots, timeout: PREBID_TIMEOUT },function(bids) { console.log("aps handler"); adServerCallback('aps'); }); // ===== Prebid callback console.log("===== set Prebid callback"); pbjs.requestBids({ bidsBackHandler: function() { console.log("prebid handler"); adServerCallback('prebid'); }, timeout: PREBID_TIMEOUT }); // ===== Safety timeout console.log("===== set Safety timeout "); setTimeout(function() { adServerCallback('timeout'); }, FAILSAFE_TIMEOUT); // }); } // ===== Combined callback (this callback will be called by Prebid, Criteo, or timeout) function adServerCallback(source) { console.log("ON adServerCallback ",source); if (window.hb_status.adserverRequestSent) return; // add source to the processed list window.hb_status.n_adserver_callback.push(source); // add this source as "bidderDone" if (source == 'aps') { googletag.cmd.push(function() { console.log("aps SET TARGETING"); apstag.setDisplayBids(); }); } else if (source == 'prebid') { // got prebid config request googletag.cmd.push(function() { pbjs.que.push(function() { console.log("pbjs SET TARGETING"); pbjs.setTargetingForGPTAsync(); // configure targeting for prebid window.hb_status.prebidTargetingSet = true; }); }); } else if (source == 'criteo') { // got criteo config request googletag.cmd.push(function() { console.log("criteo SET TARGETING"); Criteo.SetDFPKeyValueTargeting(); // This will append Criteo keywords to the adserver call }); } // check if i've completed if (window.hb_status.n_adserver_callback.length >= 3) { // if all bids have been completed googletag.pubads().refresh(); window.hb_status.adserverRequestSent = true; googletag.cmd.push(function() { console.log("REFRESH for bidders done"); googletag.pubads().refresh(); // this will will trigger the adserver calls }); } else if ("timeout" == source) { // got timeout (one of prebid or criteo or aps didn't finish in time) window.hb_status.adserverRequestSent = true; googletag.cmd.push(function() { // pbjs.setTargetingForGPTAsync(); MUST be done ANYWAY before googletag.pubads().refresh(); if (!window.hb_status.prebidTargetingSet) { pbjs.que.push(function() { console.log("setTargetingForGPTAsync on timeout"); pbjs.setTargetingForGPTAsync(); // configure targeting for prebid }); } console.log("REFRESH for timeout"); googletag.pubads().refresh(); // this will will trigger the adserver calls }); }; } //called by the html page just before "googletag.enableServices()" and after googletag.defineSlot(...)s function oz_config(googletag) { googletag_ref = googletag; googletag_ref.pubads().disableInitialLoad(); googletag_ref.pubads().enableSingleRequest(); 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"); }); // 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(); } //it should be done into the publisher's page just after this line, but better twice that none googletag_ref.enableServices(); } // 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} }); pbjs.setConfig({ "schain": { "validation": "strict", "config": { "ver":"1.0", "complete": 1, "nodes": [ { "asi":"next14.com", "sid":"23598", "hp":1 } ] } } }); 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/dagospia.it/arte/Textbox_1",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/arte/Textbox_2",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/cafonal/Textbox_1",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/cafonal/Textbox_2",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/cronache/Textbox_1",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/cronache/Textbox_2",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/homepage/Textbox_1",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/homepage/Textbox_2",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/ros_no_hp/Textbox_1",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/ros_no_hp/Textbox_2",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/video/Textbox_1",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/video/Textbox_2",plm:91640,pld:91634}, {slot:"/57491254/dagospia.it/arte/MPU_Top",plm:91641,pld:91635}, {slot:"/57491254/dagospia.it/cafonal/MPU_Top",plm:91641,pld:91635}, {slot:"/57491254/dagospia.it/cronache/MPU_Top",plm:91641,pld:91635}, {slot:"/57491254/dagospia.it/homepage/MPU_Top",plm:91641,pld:91635}, {slot:"/57491254/dagospia.it/ros_no_hp/MPU_Top",plm:91641,pld:91635}, {slot:"/57491254/dagospia.it/Speciali_Minisiti/speciale_covid19_2020/MPU_Top",plm:91641,pld:91635}, {slot:"/57491254/dagospia.it/video/MPU_Top",plm:91641,pld:91635}, {slot:"/57491254/dagospia.it/arte/MPU_Middle",plm:91642,pld:91636}, {slot:"/57491254/dagospia.it/cafonal/MPU_Middle",plm:91642,pld:91636}, {slot:"/57491254/dagospia.it/cronache/MPU_Middle",plm:91642,pld:91636}, {slot:"/57491254/dagospia.it/homepage/MPU_Middle",plm:91642,pld:91636}, {slot:"/57491254/dagospia.it/ros_no_hp/MPU_Middle",plm:91642,pld:91636}, {slot:"/57491254/dagospia.it/Speciali_Minisiti/speciale_covid19_2020/MPU_Middle",plm:91642,pld:91636}, {slot:"/57491254/dagospia.it/video/MPU_Middle",plm:91642,pld:91636}, {slot:"/57491254/dagospia.it/arte/MPU_Bottom",plm:91643,pld:91637}, {slot:"/57491254/dagospia.it/cafonal/MPU_Bottom",plm:91643,pld:91637}, {slot:"/57491254/dagospia.it/cronache/MPU_Bottom",plm:91643,pld:91637}, {slot:"/57491254/dagospia.it/homepage/MPU_Bottom",plm:91643,pld:91637}, {slot:"/57491254/dagospia.it/ros_no_hp/MPU_Bottom",plm:91643,pld:91637}, {slot:"/57491254/dagospia.it/Speciali_Minisiti/speciale_covid19_2020/MPU_Bottom",plm:91643,pld:91637}, {slot:"/57491254/dagospia.it/video/MPU_Bottom",plm:91643,pld:91637}, {slot:"/57491254/dagospia.it/arte/MaxTicker",pld:91638}, {slot:"/57491254/dagospia.it/cafonal/MaxTicker",pld:91638}, {slot:"/57491254/dagospia.it/cronache/MaxTicker",pld:91638}, {slot:"/57491254/dagospia.it/homepage/MaxTicker",pld:91638}, {slot:"/57491254/dagospia.it/ros_no_hp/MaxTicker",pld:91638}, {slot:"/57491254/dagospia.it/Speciali_Minisiti/speciale_covid19_2020/MaxTicker",pld:91638}, {slot:"/57491254/dagospia.it/video/MaxTicker",pld:91638}, {slot:"/57491254/dagospia.it/business/MaxTicker",pld:91707}, {slot:"/57491254/dagospia.it/politica/MaxTicker",pld:91707}, {slot:"/57491254/dagospia.it/sport/MaxTicker",pld:91707}, {slot:"/57491254/dagospia.it/business/MPU_Bottom",plm:91702,pld:91708}, {slot:"/57491254/dagospia.it/politica/MPU_Bottom",plm:91702,pld:91708}, {slot:"/57491254/dagospia.it/sport/MPU_Bottom",plm:91702,pld:91708}, {slot:"/57491254/dagospia.it/business/MPU_Middle",plm:91703,pld:91709}, {slot:"/57491254/dagospia.it/politica/MPU_Middle",plm:91703,pld:91709}, {slot:"/57491254/dagospia.it/sport/MPU_Middle",plm:91703,pld:91709}, {slot:"/57491254/dagospia.it/business/MPU_Top",plm:91704,pld:91710}, {slot:"/57491254/dagospia.it/politica/MPU_Top",plm:91704,pld:91710}, {slot:"/57491254/dagospia.it/sport/MPU_Top",plm:91704,pld:91710}, {slot:"/57491254/dagospia.it/business/Textbox_1",plm:91705,pld:91711}, {slot:"/57491254/dagospia.it/business/Textbox_2",plm:91705,pld:91711}, {slot:"/57491254/dagospia.it/politica/Textbox_1",plm:91705,pld:91711}, {slot:"/57491254/dagospia.it/politica/Textbox_2",plm:91705,pld:91711}, {slot:"/57491254/dagospia.it/sport/Textbox_1",plm:91705,pld:91711}, {slot:"/57491254/dagospia.it/sport/Textbox_2",plm:91705,pld:91711}, {slot:"/57491254/dagospia.it/arte/Top",plm:91639}, {slot:"/57491254/dagospia.it/cafonal/Top",plm:91639}, {slot:"/57491254/dagospia.it/cronache/Top",plm:91639}, {slot:"/57491254/dagospia.it/homepage/Top",plm:91639}, {slot:"/57491254/dagospia.it/ros_no_hp/Top",plm:91639}, {slot:"/57491254/dagospia.it/Speciali_Minisiti/speciale_covid19_2020/Top",plm:91639}, {slot:"/57491254/dagospia.it/video/Top",plm:91639}, {slot:"/57491254/dagospia.it/business/Top",plm:91706}, {slot:"/57491254/dagospia.it/politica/Top",plm:91706}, {slot:"/57491254/dagospia.it/sport/Top",plm:91706} ]; var aplus_placements = [ {pl:91640,sizes:[[300, 100]],bids:[{bidder:'appnexus', params:{placementId:'20604024'}},{bidder:'adf', params:{mid:'919617',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a9690fa017171304fb331488c580073',pos:'8a969d82017575bc3922bccf3e1a000d'}}]}, {pl:91634,sizes:[[300, 100]],bids:[{bidder:'appnexus', params:{placementId:'20603966'}},{bidder:'adf', params:{mid:'919605',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a96954b017171304c2b31488a630068',pos:'8a96940d017575bc4351bccacaaa0006'}}]}, {pl:91641,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20604029'}},{bidder:'triplelift', params:{inventoryCode:'Next14_dagospia_300x250_prebid_mobile'}},{bidder:'adf', params:{mid:'919618',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a9690fa017171304fb331488c580073',pos:'8a9690f1017575bc3e53bccfa10c0005'}}]}, {pl:91635,sizes:[[300, 250],[300, 600]],bids:[{bidder:'appnexus', params:{placementId:'20603975'}},{bidder:'triplelift', params:{inventoryCode:'Next14_dagospia_300x250_prebid_desktop'}},{bidder:'adf', params:{mid:'919607',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a96954b017171304c2b31488a630068',pos:'8a96940d017575bc4351bccb54e20007'}}]}, {pl:91642,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20604035'}},{bidder:'triplelift', params:{inventoryCode:'Next14_dagospia_300x250_prebid_mobile_middle'}},{bidder:'adf', params:{mid:'919619',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a9690fa017171304fb331488c580073',pos:'8a969d82017575bc3922bccff3e4000e'}}]}, {pl:91636,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20603982'}},{bidder:'triplelift', params:{inventoryCode:'Next14_dagospia_300x250_prebid_desktop_middle'}},{bidder:'adf', params:{mid:'919609',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a96954b017171304c2b31488a630068',pos:'8a96940d017575bc4351bccc4f8f0008'}}]}, {pl:91643,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20604039'}},{bidder:'adf', params:{mid:'919620',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a9690fa017171304fb331488c580073',pos:'8a9690f1017575bc3e53bcd052b00006'}}]}, {pl:91637,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20603988'}},{bidder:'adf', params:{mid:'919611',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a96954b017171304c2b31488a630068',pos:'8a96940d017575bc4351bccca5720009'}}]}, {pl:91638,sizes:[[728, 90],[970, 250],[990, 250],[990, 30]],bids:[{bidder:'appnexus', params:{placementId:'20604008'}},{bidder:'triplelift', params:{inventoryCode:'Next14_dagospia_970x250_prebid_desktop'}},{bidder:'adf', params:{mid:'919615',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a96954b017171304c2b31488a630068',pos:'8a96940d017575bc4351bccd02b8000a'}}]}, {pl:91707,sizes:[[728, 90]],bids:[{bidder:'appnexus', params:{placementId:'20672670'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928062',rcur:'USD'}}]}, {pl:91702,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20672638'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928067',rcur:'USD'}}]}, {pl:91708,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20672671'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928063',rcur:'USD'}}]}, {pl:91703,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20672640'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928068',rcur:'USD'}}]}, {pl:91709,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20672672'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928064',rcur:'USD'}}]}, {pl:91704,sizes:[[300, 250]],bids:[{bidder:'appnexus', params:{placementId:'20672642'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928069',rcur:'USD'}}]}, {pl:91710,sizes:[[300, 250],[300, 600]],bids:[{bidder:'appnexus', params:{placementId:'20672681'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928065',rcur:'USD'}}]}, {pl:91705,sizes:[[300, 100]],bids:[{bidder:'appnexus', params:{placementId:'20672646'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928071',rcur:'USD'}}]}, {pl:91711,sizes:[[300, 100]],bids:[{bidder:'appnexus', params:{placementId:'20672683'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928066',rcur:'USD'}}]}, {pl:91639,sizes:[[320, 50],[320, 100]],bids:[{bidder:'appnexus', params:{placementId:'20604020'}},{bidder:'triplelift', params:{inventoryCode:'Next14_dagospia_HDX_prebid'}},{bidder:'adf', params:{mid:'919616',rcur:'USD'}},{bidder:'yahoossp', params:{dcn:'8a9690fa017171304fb331488c580073',pos:'8a969d82017575bc3922bcce71c1000c'}}]}, {pl:91706,sizes:[[320, 50],[320, 100]],bids:[{bidder:'appnexus', params:{placementId:'20672649'}},{bidder:'criteo', params:{networkId:6093}},{bidder:'adf', params:{mid:'928072',rcur:'USD'}}]} ];