import wixLocation from 'wix-location'; import { session } from 'wix-storage'; $w.onReady(function () { // 🔐 Récupère le cid depuis l'URL s'il est présent (ex: ?cid=xxx) const url = new URL(wixLocation.url); const cidFromUrl = url.searchParams.get("cid"); if (cidFromUrl) { session.setItem("cid", cidFromUrl); session.setItem("sessionStarted", String(new Date().getTime())); // enregistre l'heure de début de session } const cid = session.getItem("cid"); if (cid) { const currentTime = new Date().getTime(); const lastSessionTime = parseInt(session.getItem("lastSession") || "0", 10); const isNewSession = currentTime - lastSessionTime > 30 * 60 * 1000; // nouvelle session si + de 30 min if (isNewSession) { session.setItem("lastSession", String(currentTime)); // 🧭 Envoi d'un événement "session_start" fetch("https://script.google.com/macros/s/AKfycbxc14xy5H-OuStkUV8VivyTCYOW090SMCAKKaEsOoy4xBjERzBC7VmncQRGTtcwsPpplA/exec", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ cid: cid, page: wixLocation.path.join("/"), eventType: "session_start", timestamp: new Date().toISOString() }) }) .then(res => res.text()) .then(r => console.log("Session start envoyée :", r)) .catch(err => console.error("Erreur session start :", err)); } // 📄 Envoi d'un événement "page_view" fetch("https://script.google.com/macros/s/AKfycbxc14xy5H-OuStkUV8VivyTCYOW090SMCAKKaEsOoy4xBjERzBC7VmncQRGTtcwsPpplA/exec", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ cid: cid, page: wixLocation.path.join("/"), eventType: "page_view", timestamp: new Date().toISOString() }) }) .then(res => res.text()) .then(r => console.log("Page view envoyée :", r)) .catch(err => console.error("Erreur page view :", err)); } });
top of page

Veuillez compléter les champs suivants pour envoyer votre demande.

Objectif
bottom of page