self.xpln_targeting = function(debug) { var slots = googletag.pubads().getSlots(); for (var i = 0; i < slots.length; i++) { var slot = slots[i]; var unitPath = slot.getAdUnitPath(); var keyValues = get_xpln_targeting(unitPath, debug); for (var key in keyValues) { if (keyValues.hasOwnProperty(key)) { slot.setTargeting(key, keyValues[key]); if (debug) console.log("slot=",unitPath, ", for key=",key,", value=",keyValues[key]); } } } }; self.get_xpln_targeting = function(unitPath, debug) { const data = {"all": {"31695825/lachainemeteo/webmobile_smartphone_nos/smartphone_fr_lachainemeteo_localites_pave_atf": {"xpln_v": "20_30", "xpln_v1s": "0_10", "xpln_v2s": "0_10", "xpln_v3s": "0_10", "xpln_vt": "200_300"}, "31695825/lachainemeteo/web_desktop_nos/desktop_fr_lachainemeteo_localites_mban_atf": {"xpln_v": "50_60", "xpln_v1s": "40_50", "xpln_v2s": "20_30", "xpln_v3s": "10_20", "xpln_vt": "1000_1500"}, "31695825/lachainemeteo/webmobile_smartphone_nos/smartphone_fr_lachainemeteo_localites_mban_atf": {"xpln_v": "40_50", "xpln_v1s": "10_20", "xpln_v2s": "0_10", "xpln_v3s": "0_10", "xpln_vt": "500_600"}, "31695825/lachainemeteo/web_desktop_nos/desktop_fr_lachainemeteo_localites_pave_atf": {"xpln_v": "40_50", "xpln_v1s": "20_30", "xpln_v2s": "10_20", "xpln_v3s": "0_10", "xpln_vt": "800_1000"}}}; var getDevice = function() { return "all"; }; var device = getDevice(); unitPath = unitPath.toLowerCase().replace(/^\//, ''); var targeting = data[device] ? data[device][unitPath] : {}; if (debug) console.log("unitPath=",unitPath, ", device=",device, ", targeting=",targeting); return targeting || {}; }