Flow Events

Track custom events for analytics and integrate with your app's onEvent callback.

Use trackEvent() inside your flow to send events to the Dashboard and to your app's onEvent callback. To close the flow, use Flow Control (complete(), dismiss()).

trackEvent()#

Track a custom event for analytics. Events are sent to the server and visible in the Dashboard.

Mobana.trackEvent(name: string): void
ParameterTypeDescription
nameRequiredstringEvent name. Use snake_case for consistency (e.g., step_1_completed).
flow.js
// Track user interactions for analytics
document.getElementById('step-1-btn').addEventListener('click', () => {
  Mobana.trackEvent('step_1_completed');
  showStep(2);
});

document.getElementById('watch-video-btn').addEventListener('click', () => {
  Mobana.trackEvent('video_started');
  playVideo();
});

// Track feature discovery
document.querySelectorAll('.feature-card').forEach((card, index) => {
  card.addEventListener('click', () => {
    Mobana.trackEvent('feature_explored');
  });
});

Event Naming Best Practices#

// Good event names (snake_case, descriptive)
Mobana.trackEvent('welcome_viewed');
Mobana.trackEvent('step_1_completed');
Mobana.trackEvent('notification_permission_granted');
Mobana.trackEvent('plan_selected');
Mobana.trackEvent('video_watched');

// Avoid these patterns
Mobana.trackEvent('click');           // Too generic
Mobana.trackEvent('StepCompleted');   // Use snake_case
Mobana.trackEvent('step 1');          // No spaces
  • Use snake_case: Consistent with conversion tracking and industry standards.
  • Be descriptive: Event names should clearly indicate what happened.
  • Include context: Use prefixes like step_, feature_, permission_.
  • Avoid generic names: click or button don't tell you anything useful.

onEvent Callback#

When you call trackEvent(), the event is also sent to the onEvent callback in the app (if provided):

app.tsx
// In the app:
const result = await Mobana.startFlow('onboarding', {
  onEvent: (eventName) => {
    // Called whenever the flow calls trackEvent()
    analytics.track(eventName);
  },
});

System Events#

These events are tracked automatically by the SDK:

  • __started__ — Flow was shown
  • __completed__ — User completed the flow
  • __dismissed__ — User dismissed the flow

Don't use event names starting with __ — these are reserved for system events.