// In Site Code (make sure Dev Mode is enabled) import wixLocation from 'wix-location'; import { session } from 'wix-storage'; $w.onReady(() => { // Check for the gclid parameter in the URL const gclid = wixLocation.query["gclid"]; if (gclid) { // Store it in session storage (persists during the visitor’s session) session.setItem("gclid", gclid); console.log("gclid captured:", gclid); } }); // Import required modules import { session } from 'wix-storage'; import wixData from 'wix-data'; // This code runs when the page is ready $w.onReady(() => { // Attach an event handler to your checkout button. // Make sure your button's ID is "btnCheckout" or update the selector accordingly. $w("#btnCheckout").onClick(() => { // Retrieve the gclid from session storage (captured in Step 1) const gclid = session.getItem("gclid") || ""; // Generate a unique order ID. Here we use the current timestamp. const orderId = new Date().getTime().toString(); // Create an object representing the new order record. const orderRecord = { orderId: orderId, gclid: gclid, status: "initiated" // you can update this later via Zapier when conversion is confirmed }; // Insert the record into the "Orders" collection wixData.insert("Orders", orderRecord) .then((result) => { console.log("Order record created:", result); // Optionally, save the orderId in session storage for later reference: session.setItem("orderId", result.orderId); // If your built-in Stripe Checkout integration automatically opens a popup, // you don't need to add additional code here. // The order record is now stored for your Zapier workflow. }) .catch((err) => { console.error("Error creating order record:", err); }); }); });