try { var POLL_INTERVAL = 10; // Max number of poll attempts var MAX_POLL_COUNT = 10; var pollCount = 0; function poll() { pollCount++; if ((window.Dmdbase_CDC && window.Dmdbase_CDC.CompanyProfile && window.Dmdbase_CDC.targetReady === true) || pollCount === MAX_POLL_COUNT) { adobe.target.getOffer({ "mbox": "target-global-mbox", "success": function(offers) { adobe.target.applyOffer({ "mbox": "target-global-mbox", "offer": offers }); }, "error": function(status, error) { if (console && console.log) { console.log(status); console.log(error); } }, "timeout": 5000 }); clearTimeout(poll); } else if (pollCount < MAX_POLL_COUNT) { //console.log("global mbox not found yet"); setTimeout(poll, POLL_INTERVAL); } } poll(); } catch (e) { console.log(e); }