var revDiv = document.querySelector('script[id="rc_110"]').parentNode; var cs = document.createElement("script"); cs.type = 'text/javascript'; cs.src = "https://static.criteo.net/js/ld/publishertag.js"; cs.async = true; revDiv.appendChild(cs); cs.addEventListener('load', function() { callCriteo_rc_110(); }); function callCriteo_rc_110() { var adUnits = { "placements": [ { 'slotid': 'rev-0', 'zoneid': 726293, 'nativeCallback': function(){} }, ] }; Criteo.events.push(function() { Criteo.RequestBids(adUnits, callRev_rc_110, 500); }); } var callRev_rc_110 = function(response) { try { if(Array.isArray(response)) { response = revMap(response); } else { response = ''; } var rcxhr = new XMLHttpRequest(); rcxhr.onreadystatechange = function() { if (rcxhr.readyState == 4) { var rcel = document.createElement("script"); rcel.type = 'text/javascript'; rcel.text = rcxhr.responseText; rcel.async = true; revDiv.appendChild(rcel); } } rcxhr.open("POST", "//trends.revcontent.com/serve.js.php?w=5249&t=rc_110&c=1500855498764&width=1856&referer=", true); rcxhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); rcxhr.withCredentials = true; rcxhr.send('criteo=' + response); } catch(e) { var rcel = document.createElement("script"); rcel.id = 'rc_' + Math.floor(Math.random() * 1000); rcel.type = 'text/javascript'; rcel.src = "//trends.revcontent.com/serve.js.php?criteo=&w=5249&t=rc_110&c=1500855498764&width=1856&referer="; rcel.async = true; revDiv.appendChild(rcel); } }; function revMap(response) { var final = []; var c = 0; var dupe; response.sort(function(a,b){ return b.cpm - a.cpm }); response.forEach(function(r, index) { dupe = false; final.forEach(function(f, i) { if(r.nativePayload.products[0].title == f.headline) { dupe = true; } }); if (!dupe && final.length < 1) { final[c] = {}; final[c].headline = r.nativePayload.products[0].title; final[c].price = r.nativePayload.products[0].price; final[c].target_url = r.nativePayload.products[0].click_url; final[c].image_url = r.nativePayload.products[0].image.url; final[c].cpm = r.cpm; final[c].pixels = []; final[c].advertiser = r.nativePayload.advertiser.description; final[c].optout_click_url = r.nativePayload.privacy.optout_click_url; final[c].optout_image_url = r.nativePayload.privacy.optout_image_url; r.nativePayload.impression_pixels.forEach(function(p, i) { final[c].pixels.push(p.url); }); c++; } }); return encodeURIComponent(JSON.stringify(final)); }1