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 | nullconst 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();
}
}| Property | Type | Description |
|---|---|---|
utm_source | string | undefined | Traffic source |
utm_medium | string | undefined | Marketing medium |
utm_campaign | string | undefined | Campaign name |
utm_content | string | undefined | Ad content |
utm_term | string | undefined | Search keywords |
data | object | undefined | Custom deeplink data |
confidence | number | Match 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>// 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(): stringconst 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'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 }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);| Property | Type | Description |
|---|---|---|
top | number | Inset from top (status bar, notch) in points |
bottom | number | Inset from bottom (home indicator) in points |
left | number | Inset from left (usually 0) in points |
right | number | Inset from right (usually 0) in points |
width | number | Full screen width in points |
height | number | Full 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'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): voidgetLocalData()#
Mobana.getLocalData(key: string): any// 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.