Data Access

Access attribution data, parameters, and device information inside your flows.

getAttribution()#

Get the attribution data for this install. Returns the same data as the SDK's getAttribution() method.

Mobana.getAttribution(): Attribution | null
flow.js
const attribution = Mobana.getAttribution();

if (attribution) {
  console.log('Source:', attribution.utm_source);
  console.log('Campaign:', attribution.utm_campaign);
  console.log('Custom data:', attribution.data);
  
  // Personalize based on campaign
  if (attribution.utm_campaign === 'premium_promo') {
    showPremiumOffer();
  }
}
PropertyTypeDescription
utm_sourcestring | undefinedTraffic source
utm_mediumstring | undefinedMarketing medium
utm_campaignstring | undefinedCampaign name
utm_contentstring | undefinedAd content
utm_termstring | undefinedSearch keywords
dataobject | undefinedCustom deeplink data
confidencenumberMatch confidence (0.0 - 1.0)

Returns null if no attribution match was found (organic install).

getParams()#

Get custom parameters passed from the app via startFlow().

Mobana.getParams(): Record<string, unknown>
flow.js
// In your app:
// await Mobana.startFlow('welcome', { params: { userName: 'John', isPremium: true } });

// In your flow:
const params = Mobana.getParams();

document.getElementById('greeting').textContent = `Hello, ${params.userName || 'there'}!`;

if (params.isPremium) {
  document.getElementById('premium-badge').style.display = 'block';
}

Use params to personalize flows based on user state, feature flags, or any app context.

getInstallId()#

Get the unique install ID for this device.

Mobana.getInstallId(): string
const installId = Mobana.getInstallId();
console.log('Install ID:', installId); // e.g., "520e8400-c466-a554-40e0-0..."

getPlatform()#

Get the current platform ("ios" or "android").

Mobana.getPlatform(): 'ios' | 'android'
flow.js
const platform = Mobana.getPlatform();

if (platform === 'ios') {
  // Show iOS-specific UI (e.g., ATT prompt explanation)
  document.getElementById('att-section').style.display = 'block';
} else {
  // Android-specific UI
  document.getElementById('android-section').style.display = 'block';
}

getSafeArea()#

Get safe area insets for the device (notch, home indicator, etc.).

Mobana.getSafeArea(): { top, bottom, left, right, width, height }
flow.js
const safeArea = Mobana.getSafeArea();

// Apply safe area padding
document.body.style.paddingTop = safeArea.top + 'px';
document.body.style.paddingBottom = safeArea.bottom + 'px';

// Or use CSS variables (recommended)
// padding-top: var(--safe-area-top);
// padding-bottom: var(--safe-area-bottom);
PropertyTypeDescription
topnumberInset from top (status bar, notch) in points
bottomnumberInset from bottom (home indicator) in points
leftnumberInset from left (usually 0) in points
rightnumberInset from right (usually 0) in points
widthnumberFull screen width in points
heightnumberFull screen height in points

Prefer using CSS variables (var(--safe-area-top)) over JavaScript for layout. See CSS Variables.

getColorScheme()#

Get the device's color scheme (light or dark mode).

Mobana.getColorScheme(): 'light' | 'dark'
flow.js
const colorScheme = Mobana.getColorScheme();

if (colorScheme === 'dark') {
  document.body.classList.add('dark-mode');
} else {
  document.body.classList.add('light-mode');
}

// Or use CSS (recommended)
// @media (prefers-color-scheme: dark) { ... }
// Or: body { color-scheme: var(--color-scheme); }

Local Data Storage#

Store and retrieve data that persists across flow sessions on the device.

setLocalData()#

Mobana.setLocalData(key: string, value: any): void

getLocalData()#

Mobana.getLocalData(key: string): any
flow.js
// Store data that persists across flow sessions
Mobana.setLocalData('onboarding_step', 3);
Mobana.setLocalData('preferences', { notifications: true });

// Retrieve stored data
const step = Mobana.getLocalData('onboarding_step'); // 3
const prefs = Mobana.getLocalData('preferences'); // { notifications: true }

// Use case: Resume onboarding where user left off
const lastStep = Mobana.getLocalData('last_completed_step') || 0;
goToStep(lastStep + 1);

Local data is stored in the app's AsyncStorage and persists until the user calls reset() or uninstalls the app.