(function(i, s, o, g, r, a, m) { i["GoogleAnalyticsObject"] = r; (i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments); }), (i[r].l = 1 * new Date()); (a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]); a.async = 1; a.src = g; m.parentNode.insertBefore(a, m); })( window, document, "script", "https://www.google-analytics.com/analytics.js", "ga" ); ga("create", "UA-36127368-4", { cookieFlags: "secure;SameSite=None", cookieDomain: "none", }); ga("set", "checkStorageTask", null); ga("send", "pageview"); var CRUNCHO_NOW_URL = "https://stockholmmitti-iframe.cruncho.co/now"; function init_cruncho_iframe() { document.getElementById("cruncho_now_iframe").src = CRUNCHO_NOW_URL } function sendGA(event) { if (typeof event.data === "string" && event.data === "sendGA") ga(function(tracker) { // Gets the client ID of the default tracker. var clientId = tracker.get("clientId"); console.log({ clientId }); console.log("Posting message"); // Here it could break, I couldn't make it work with document reference window.frames[0].postMessage({ clientId }, "*"); }); } window.addEventListener("message", sendGA, false); window.onload = init_cruncho_iframe