getAttribution()
Retrieve attribution data for this install. Returns cached result if available.
Method Signature#
Mobana.getAttribution<T>(options?: GetAttributionOptions): Promise<Attribution<T> | null>Usage#
App.tsx
const attribution = await Mobana.getAttribution();
if (attribution) {
console.log('Source:', attribution.utm_source);
console.log('Campaign:', attribution.utm_campaign);
console.log('Confidence:', attribution.confidence);
}Never throws. Returns null on error or if no attribution match was found. This is intentional to never block your app flow.
Parameters#
| Parameter | Type | Description |
|---|---|---|
timeout | number= 10000 | Timeout in milliseconds for the attribution request. |
const attribution = await Mobana.getAttribution({
timeout: 5000, // 5 second timeout (default is 10 seconds)
});Return Value#
Returns an Attribution object if a match was found, or null if no match or an error occurred.
| Property | Type | Description |
|---|---|---|
utm_source | string | undefined | Traffic source (e.g., 'facebook', 'google', 'tiktok') |
utm_medium | string | undefined | Marketing medium (e.g., 'cpc', 'social', 'email') |
utm_campaign | string | undefined | Campaign name |
utm_content | string | undefined | Ad content identifier |
utm_term | string | undefined | Search keywords |
data | T | undefined | Custom deeplink data passed through the redirect URL |
confidence | number | Match confidence score (0.0 - 1.0). 1.0 = deterministic match, <1.0 = probabilistic match. |
TypeScript Generics#
Use generics to get type-safe access to your custom deeplink data:
App.tsx
// Define your custom data type
interface MyDeeplinkData {
promo?: string;
referrerId?: string;
productId?: number;
}
// Use generics for type-safe data access
const attribution = await Mobana.getAttribution<MyDeeplinkData>();
if (attribution?.data?.promo) {
applyPromoCode(attribution.data.promo); // Type-safe!
}Understanding Confidence Scores#
The confidence field indicates how certain the attribution match is:
const attribution = await Mobana.getAttribution();
if (attribution) {
if (attribution.confidence === 1.0) {
// Deterministic match via Android Install Referrer
console.log('100% certain this user came from:', attribution.utm_source);
} else if (attribution.confidence > 0.8) {
// High confidence probabilistic match
console.log('Likely came from:', attribution.utm_source);
} else {
// Lower confidence - use with caution
console.log('Possible source:', attribution.utm_source);
}
}- 1.0 (Deterministic): Match via Android Install Referrer. 100% accurate.
- <1.0 (Probabilistic): Match based on IP address, timezone, screen size, and language. Accuracy depends on signal quality.
Caching Behavior#
- In-memory cache: Results are cached in memory for instant access on subsequent calls.
- Persistent cache: Results are also stored in AsyncStorage for app restarts.
- Idempotent: Multiple calls return the same cached result. The server also caches by install ID.
Call getAttribution() as many times as you need — it's efficient due to caching. You won't incur additional API calls or billing.
Analytics Integration#
App.tsx
const attribution = await Mobana.getAttribution();
if (attribution) {
// Send to your analytics provider
Amplitude.setUserProperties({
'install_source': attribution.utm_source,
'install_campaign': attribution.utm_campaign,
'install_medium': attribution.utm_medium,
});
// Or Mixpanel
Mixpanel.people.set({
'$utm_source': attribution.utm_source,
'$utm_campaign': attribution.utm_campaign,
});
}