> For the complete documentation index, see [llms.txt](https://docs.ingestlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ingestlabs.com/implementation/web-sdk/installation/ingest-labs-script.md).

# 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.

```javascript
!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);
    }
  }
})();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ingestlabs.com/implementation/web-sdk/installation/ingest-labs-script.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
