For the complete documentation index, see llms.txt. This page is also available as Markdown.

Ingest Labs Script

The below Ingest Labs script can be used on both staging and production websites. It takes into account - the domain name, and switches the sdks between production and non-production websites.

Place this SDK as high up the website as possible.

!function(e,t,n,r){e.eedl||(e.mpDl=e.mpDl||[],e.eedl=e.eedl||function(){e.mpDl.push(Array.from(arguments))})}(window,document),function(e){function t(e,t,n){e[t]||(e[t]=n)}e._mp=e._mp||{},t(e._mp,"triggerEvent",(function(t,n,r){e._mp.safeExecute("triggerEvent",(function(e,t,n){if(t=t||{},n=n||window,e){var r=new CustomEvent(e,{detail:t});n.dispatchEvent(r)}}))(t,n,r)})),t(e._mp,"onDocumentReady",(function(t){/in/.test(document.readyState)?setTimeout(e._mp.onDocumentReady,9,t):t()})),t(e._mp,"waitUntil",(function(e,t,n,r){var o=n,a=setInterval((function(){try{var i=e.call(this);void 0===i||!1===i?o<t?o+=n:clearInterval(a):(clearInterval(a),r())}catch(e){}}),n)})),t(e._mp,"addScript",(function(t,n,r){e._mp.safeExecute("triggerEvent",(function(e,t,n){var r=document.createElement("script");r.id=e,r.async=n,r.src=t;var o=document.getElementsByTagName("script")[0]||document.getElementsByTagName("head")[0];o?o.parentNode.insertBefore(r,o):console&&console.error&&console.error("Could not append script with id: ",e," because no appendTo element was found")}))(t,n,r)})),t(e._mp,"safeExecute",(function(t,n){return function(){try{return n.apply(this,arguments)}catch(n){e._mp.mpReportErr(t,n.message,n&&n.stack?n.stack.toString():"")}}})),t(e._mp,"mpReportErr",(function(t,n,r,o){var a={errKey:t,errMessage:n,errStack:r,errLang:o||"js"};e._mp.triggerEvent("mp_log_err",{msg:n||"EEDL Err",payload:a}),e._mp.triggerEvent("mp_rpt_err",{err:a})})),t(e._mp,"mpReportMsg",(function(){e._mp.triggerEvent("mp_log_msg",{payload:arguments})})),t(e._mp,"setSessionVar",(function(t,n){return e._mp.safeExecute("setSessionVar",(function(e,t){return window.sessionStorage.setItem(e,t)}))(t,n)})),t(e._mp,"getSessionVar",(function(t){return e._mp.safeExecute("getSessionVar",(function(e){return window.sessionStorage.getItem(e)||null}))(t)})),t(e._mp,"getCookie",(function(e){var t=document.cookie.match(new RegExp("(^| )"+e+"=([^;]+)"));return t?t[2]:null}))}(window);
(function() {
  try {
    var mpVendorId = '<VENDOR_ID>';
    var mpProjectId = '<PROJECT_ID>';
    var idlFile = "https://mp.<WEBSITE_DOMAIN>/idl/" + mpVendorId + "/idl.js";
    var scriptFile = 'https://mp.<WEBSITE_DOMAIN>/c-sdk/' + mpProjectId + '.js';
    var shouldExecuteIdl = !window._mp.getCookie('_mplidl');
    if (shouldExecuteIdl) {
      _mp.addScript('mp-idl-sdk', idlFile, false);
    }
    var hasBeenAdded = document.getElementById('mp-sdk');
    if (!hasBeenAdded) {
      _mp.addScript('mp-sdk', scriptFile, true);
    }
  } catch(err) {
    if (console && console.error) {
      console.error(err);
    }
  }
})();

Last updated