Medos Booking Docs
Callbacks & Events

Analytics recipes

Send widget events to GA4, Google Tag Manager, and Mixpanel.

The widget doesn't ship its own analytics — you own the data. Use the three callbacks (onSuccess, onError, onClose) to send events to whichever tool you use.

GA4 (gtag)

MedosBooking.init({
  apiKey: "mk_...",
  onSuccess: (data) => {
    gtag("event", "generate_lead", {
      event_category: "medos_booking",
      appointment_id: data.appointmentId ?? null,
      token_number: data.tokenNumber ?? null,
    });
  },
  onError: (err) => {
    gtag("event", "medos_booking_error", {
      error_message: err.message,
    });
  },
});

Google Tag Manager

Push events onto dataLayer and let GTM handle routing:

MedosBooking.init({
  apiKey: "mk_...",
  onSuccess: (data) => {
    window.dataLayer?.push({
      event: "medos_booking_success",
      appointmentId: data.appointmentId,
      tokenNumber: data.tokenNumber,
    });
  },
});

Mixpanel

MedosBooking.init({
  apiKey: "mk_...",
  onSuccess: (data) => {
    mixpanel.track("Booking Completed", {
      appointmentId: data.appointmentId,
      tokenNumber: data.tokenNumber,
    });
  },
  onError: (err) => {
    mixpanel.track("Booking Error", { message: err.message });
  },
});

Tracking the full funnel

The three callbacks cover success, error, and close — but not step-by-step funnel events (patient entered phone, verified OTP, etc.). Those aren't currently exposed. If you need them, talk to the platform team about custom hooks.

Don't send PII

Never send patient names, phone numbers, or emails to third-party analytics without explicit consent — GA4 and Mixpanel both prohibit PII in event properties. Stick to booking IDs and token numbers.

On this page