Skip to main content

Installation

npm install despia-native
import despia from 'despia-native';
Connect your TikTok and Meta ad accounts to AppsFlyer to get accurate install attribution, event postbacks, and ROAS reporting per campaign. Combined with conversion events from the Events page, this gives you a full picture of which campaigns drive the most valuable users, not just the most installs.

Connect Partners in AppsFlyer Dashboard

For install attribution and event postbacks to flow to Meta and TikTok you need to connect them as integrated partners.
1

Open Integrated Partners

In your AppsFlyer dashboard, go to Configuration > Integrated Partners
2

Connect Meta

Find Meta ads, click Edit, enable the integration, and enter your Meta App ID
3

Map conversion events

Under In-App Events, map af_purchase, af_subscribe, and any other conversion events you want Meta to optimize for
4

Repeat for TikTok

Find TikTok for Business and repeat the same process
Set event postbacks to All media sources including organic for the Install event. This ensures Meta and TikTok receive data for all installs, not just their own attributed ones.

Create campaign-specific OneLink URLs to track performance per campaign, ad set, or creative.
1

Open OneLink Management

Go to Engage > OneLink Management in your AppsFlyer dashboard
2

Create a link

Select your OneLink template and click Add Link
3

Configure the link

Set the media source, campaign name, and any custom parameters like deep_link_value or page_id
4

Use in your ads

Paste the generated link directly into your TikTok or Meta ad creative as the destination URL
https://yourapp.onelink.me/xxxx?pid=tiktokads_int&c=summer_2025&deep_link_value=product&page_id=sneaker_42

Ad Revenue Tracking

Report impression-level ad revenue back to AppsFlyer per platform. This enables LTV and ROAS reporting per acquisition channel so you can see which campaigns drive the most revenue, not just the most installs. Use log_ad_revenue each time an ad is shown to the user.
const metaRevenue = {
    "ad_platform": "facebook",
    "currency": "USD",
    "revenue": 0.008,
    "ad_type": "interstitial",
    "ad_unit_id": "your_unit_id"
}
despia("appsflyer://log_ad_revenue?" + new URLSearchParams(metaRevenue).toString())
ad_platform
string
required
Ad network name. Accepted values: "facebook", "tiktok", "admob"
currency
string
required
3-character ISO 4217 currency code, e.g. "USD", "EUR", "AED". Defaults to "USD" if omitted.
revenue
number
required
Revenue amount for this ad impression. No commas or currency signs.
ad_type
string
Type of ad served. Accepted values: "banner", "interstitial", "rewarded", "native"
ad_unit_id
string
Your ad unit ID from the ad network

Web-to-App Attribution

If users discover your app through your website before installing, add the AppsFlyer Smart Banner to stitch the web visit to the app install. Without this, users who visit your site and later install the app will appear as organic in AppsFlyer. Add this to your website <head>:
<script>
!function(t,e,n,s,a,c,i,o,p){t.AppsFlyerSdkObject=a,t.AF=t.AF||function(){
(t.AF.q=t.AF.q||[]).push([Date.now()].concat(Array.prototype.slice.call(arguments)))},
t.AF.id=t.AF.id||i,t.AF.plugins={},o=e.createElement(n),p=e.getElementsByTagName(n)[0],o.async=1,
o.src="https://websdk.appsflyersdk.com?"+(c.length>0?"st="+c.split(",").sort().join(",")+"&":"")+(i.length>0?"af_id="+i:""),
p.parentNode.insertBefore(o,p)}(window,document,"script",0,"AF","banners",{banners:{key:"YOUR_WEB_KEY"}});
AF('banners', 'showBanner');
</script>
Replace YOUR_WEB_KEY with the web key from your AppsFlyer dashboard under Settings > Brand Bundles > Web dev key. This is a web-only change. No native code changes are required.

Frequently Asked Questions

If you install Meta SDK and TikTok SDK separately, each platform only sees its own data and will overclaim credit for the same install. AppsFlyer acts as a neutral middleman. It determines which channel actually gets credit using last-click attribution and reports back to each platform what it earned. Your ROAS numbers become trustworthy.
No, and that is expected. Meta and TikTok use their own attribution models which typically show higher install counts than AppsFlyer. AppsFlyer’s numbers are more accurate for your own budget decisions. Use AppsFlyer to decide where to spend, use Meta and TikTok dashboards to manage creatives.
Map af_complete_registration, af_purchase, and af_subscribe at minimum. These give the ad algorithms enough signal to find users likely to convert. If you only map installs, the algorithms optimize for install volume which rarely correlates with revenue.

Resources

NPM Package

Install the Despia SDK

Smart Banners Docs

AppsFlyer Smart Banner SDK reference

Meta Ads Integration

Meta ads event mapping guide

Support

Contact our support team