). * * What it does: * Reads the hubspotutk cookie set by HubSpot's tracking script * and saves it as a Shopify cart attribute so it survives through * checkout and is available on the order object when webhooks fire. */ (function () { // Read the hubspotutk cookie const hutk = document.cookie .split("; ") .find((row) => row.startsWith("hubspotutk=")) ?.split("=")[1]; if (!hutk) return; // HubSpot tracking script hasn't fired yet — skip // Save to Shopify cart attributes via Ajax API fetch("/cart/update.js", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ attributes: { hubspotutk: hutk }, }), }) .then(() => console.debug("[Irrigreen] hubspotutk saved to cart attributes")) .catch((err) => console.warn("[Irrigreen] Failed to save hubspotutk:", err)); })();