Skip to main content
AppsFlyer attribution, deep linking, and event tracking. Fully bridged to your web layer. Know exactly where every user came from, route them to the right page on install, and send conversion events back to Meta and TikTok without writing a line of native code.
AppsFlyer must be enabled in Despia > App > Settings > Integrations > AppsFlyer and your AppsFlyer dev key configured before any data will flow.

Installation

npm install despia-native
import despia from 'despia-native';

How it works

Despia activates the native AppsFlyer SDK at install time and caches attribution data locally on the device. On every subsequent page load, three variables are injected automatically into your web layer with no setup, no requests, no waiting.
despia.appsFlyerAttribution  // full attribution object
despia.appsFlyerReferrer     // e.g. "tiktok_ad", "facebook_organic", "organic"
despia.appsFlyerUID          // unique AppsFlyer user ID
Events fired from your web layer using despia("appsflyer://...") are intercepted natively and forwarded to AppsFlyer in real time. AppsFlyer then postbacks to your connected partners (Meta, TikTok, Google) based on your dashboard configuration. Emails and phone numbers are hashed with SHA256 automatically before transmission.

Attribution

Read where every user came from across TikTok, Meta, Google, affiliate, or organic.

Deep Linking

Route users to specific pages inside the app from ad campaigns.

Ad Campaigns

Track ad revenue per platform and measure ROAS per acquisition channel.

Events

Log standard and custom in-app events back to Meta and TikTok.

User Identification

Call set_user_id as soon as the user logs in. This ties all subsequent events to your internal user ID across AppsFlyer, Meta, and TikTok dashboards.
const userId = "user_123"
despia("appsflyer://set_user_id?customer_user_id=" + encodeURIComponent(userId))
Pass email and phone for audience matching. Both are hashed with SHA256 automatically before being sent. You never transmit raw PII.
const email = "user@example.com"
despia("appsflyer://set_email?email=" + encodeURIComponent(email))

const phone = "+15550001234"
despia("appsflyer://set_phone?phone=" + encodeURIComponent(phone))
If you need the AppsFlyer UID immediately in the same flow, use the await pattern:
const data = await despia("appsflyer://get_uid", ["appsFlyerUID"])
const uid = data.appsFlyerUID
// use uid immediately, e.g. send to your backend

Call set_consent based on the user’s cookie banner choice. Required for GDPR compliance. Controls whether AppsFlyer tracks the user at all.
const isGdpr = true
const hasConsent = true
despia("appsflyer://set_consent?is_gdpr=" + encodeURIComponent(isGdpr) + "&has_consent=" + encodeURIComponent(hasConsent))

Resources

NPM Package

Install the Despia SDK

AF Events Reference

Full list of standard AppsFlyer events

Support

Contact our support team