CustomizationCallbacks & 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.

Conversion tracking won't fire yet

Every recipe below reports the conversion from onSuccess, and onSuccess is not currently invoked, so the booking event will never reach your analytics. onClose works, and onError fires only when the widget fails to start. Wire these up by all means, but don't switch off an existing conversion source until the platform team confirms onSuccess is live.

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

Step-by-step funnel events — patient entered phone, verified OTP, picked a slot — aren't exposed at all. Combined with onSuccess not firing, the only funnel signal you can currently collect from the widget is "the modal was closed". If you need real funnel instrumentation, talk to the platform team.

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