// === Edgee SDK: load immediately, once per page ===
const EDGEE_SDK_SRC = "https://YOUR-DOMAIN.com/_edgee/shopify.js";
// Expose Shopify pixel context to the SDK
// These objects are available in the pixel sandbox and need to be passed to the Edgee SDK
window.__SHOPIFY_PIXEL_CONTEXT__ = {
analytics: analytics,
browser: browser,
init: init
};
function loadScriptOnce(src, id) {
if (window.__EDGEE_SDK_PROMISE__) return window.__EDGEE_SDK_PROMISE__;
window.__EDGEE_SDK_PROMISE__ = new Promise((resolve, reject) => {
if (document.getElementById(id)) return resolve("already-loaded");
const s = document.createElement("script");
s.id = id;
s.async = true;
s.src = src;
s.onload = () => resolve("loaded");
s.onerror = (e) => reject(e);
(document.head || document.documentElement).appendChild(s);
});
return window.__EDGEE_SDK_PROMISE__;
}
// kick off load now
loadScriptOnce(EDGEE_SDK_SRC, "__EDGEE_SDK__").catch((e) => {
console.error("[Pixel] Edgee SDK load failed", e);
});