<script>
function logEvent(eventType, message) {
console.log("Event Logged:", eventType, message?.data);
}
function safeGtagEvent(eventName, params) {
if (typeof window.gtag === "function") {
window.gtag("event", eventName, params);
} else {
console.warn("gtag not available yet. Event skipped:", eventName, params);
}
}
function onMessage(message) {
const type = message?.data?.type;
if (!type || typeof type !== "string") return;
if (!type.startsWith("bridallive.")) return;
logEvent(type, message);
if (type === "bridallive.appointment_type_selected") {
console.log("Appointment Type Selected");
safeGtagEvent("appointment_type_selected", {
event_category: "Appointment",
event_label: "Appointment Type Selected"
});
}
if (type === "bridallive.event_scheduled") {
safeGtagEvent("appointment_submitted", {
event_category: "Scheduler",
event_label: "Submit",
value: 1
});
}
}
window.addEventListener("message", onMessage);</script>