Connecting Mailgun to AppsFlyer
Mailgun is developer-facing email infrastructure, which means the sending logic lives in your application and the marketing team frequently does not know what is being sent or when. AppsFlyer exists because mobile app attribution is a different problem from web attribution, and on iOS a large share of it is now aggregated and delayed by design rather than by accident. The join between them succeeds or fails on one thing: whether the AppsFlyer device identifier, appsflyer_id reaches the Mailgun message before the conversion happens, because AppsFlyer can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Mailgun links that open your app and attribute in AppsFlyer
Mailgun's click tracking rewrites OneLinks through its tracking domain, so iOS opens Safari instead of the app. Turn off click tracking on those messages, or serve the association file from your tracking subdomain per AppsFlyer guidance, and test on a real iPhone. Post nothing from Mailgun; in-app purchases go to AppsFlyer's server-to-server API from billing with the stored appsflyer_id.
The usual reason Mailgun and AppsFlyer meet is a OneLink placed in an application email so the tap opens the app. Mailgun's click tracking rewrites every link through your tracking domain first, and iOS will only open an app from a Universal Link on a domain the app is associated with. The rewritten link points at Mailgun's tracking domain, so the tap opens Safari instead, and the deep link context is degraded or lost.
Two workable fixes. Turn off click tracking for the messages that carry OneLinks, which costs you Mailgun click data on those sends, or follow AppsFlyer's guidance for email click domains so your tracking subdomain serves the association file; check whether AppsFlyer documents Mailgun specifically before committing to that route. Either way, test on a real iPhone with the app installed and without it, because the two cases fail differently.
For revenue, do not post anything from Mailgun. When an email-driven user later buys in the app, the purchase goes to AppsFlyer's server-to-server events API from your billing system with that user's appsflyer_id, which Mailgun never sees. Store the device identifier against the user record when the SDK reports it, and the email's role shows up as the OneLink campaign rather than as a Mailgun event.
Mailgun → AppsFlyer · what breaks
Why this join usually fails — Mailgun → AppsFlyer
- 01
The AppsFlyer device identifier, appsflyer_id never reaches Mailgun
No session, no click, and the trigger conditions are buried in application code rather than in a campaign tool.
- 02
Nobody able to say why a message was sent
When send logic lives in application code, the marketing team cannot audit it and the engineering team is not thinking about attribution. Messages accumulate, nobody owns the list, and any analysis of email's contribution is unreliable.
- 03
Web conversions sent to a mobile attribution platform
This is the common error and it produces confident nonsense. A purchase made on your website has no device identifier and no install behind it. AppsFlyer will either discard it or attribute it to nothing, and the revenue disappears somewhere between the two systems without anyone noticing it went.
- 04
Nothing reconciles afterwards
AppsFlyer shows the event on the raw data export with its attributed media source. Check the raw export, not the aggregate dashboard, and confirm the event carries a device identifier rather than landing as organic.
Mailgun → AppsFlyer · the fix
What working looks like — Mailgun → AppsFlyer
The AppsFlyer device identifier, appsflyer_id on every message
Conversions arriving in AppsFlyer
The event is attributed to the install source, forwarded to whichever networks are configured, and appears in the cohort reporting.
Reconciled against the source
Mailgun → AppsFlyer · architecture
How Mailgun and AppsFlyer actually connect
- 1
Mailgun holds the truth
Because sends are triggered in code, the only reliable description of why a message went out lives in your application, not in Mailgun's logs.
- 2
AppsFlyer needs a click to match
AppsFlyer needs the device identifier and an event name it recognizes, plus the revenue value for in-app purchases. A server event about a user with no linked device cannot be attributed to an install.
- 3
The identifier is the bridge
The AppsFlyer device identifier, appsflyer_id, captured at the visit and carried into the Mailgun message.
- 4
The event source decides reliability
Send orders. Use Mailgun events for deliverability monitoring only.
- 5
Deduplication at the destination
AppsFlyer deduplicates in-app events by its own event identifier. Sending the same purchase from both the SDK and your server produces two events and double-counts revenue in every dashboard downstream, including the ad networks AppsFlyer forwards to.
Mailgun → AppsFlyer · normal or broken
Working vs. broken, side by side — Mailgun → AppsFlyer
Normal, not a fault
The AppsFlyer device identifier, appsflyer_id present on the message
Sent from your order system
Deduplicated correctly
AppsFlyer deduplicates in-app events by its own event identifier. Sending the same purchase from both the SDK and your server produces two events and double-counts revenue in every dashboard downstream, including the ad networks AppsFlyer forwards to.
Reconciles with the source
Actually broken
The AppsFlyer device identifier, appsflyer_id missing on most records
No session, no click, and the trigger conditions are buried in application code rather than in a campaign tool.
Sent from the browser
When send logic lives in application code, the marketing team cannot audit it and the engineering team is not thinking about attribution. Messages accumulate, nobody owns the list, and any analysis of email's contribution is unreliable.
Counted twice, or not at all
This is the common error and it produces confident nonsense. A purchase made on your website has no device identifier and no install behind it. AppsFlyer will either discard it or attribute it to nothing, and the revenue disappears somewhere between the two systems without anyone noticing it went.
Nobody has reconciled it
Mailgun → AppsFlyer · diagnose
Diagnostic order — Mailgun → AppsFlyer
- 01
Count messages carrying the AppsFlyer device identifier, appsflyer_id
- 02
Follow one real conversion end to end
- 03
Inventory every code path that triggers a send
Usually the first time anyone has, and it frequently finds sends nobody remembers building.
- 04
Check what share of your revenue happens in the app at all
If most purchases are on the web, AppsFlyer is not your conversion destination and the work belongs somewhere else entirely.
- 05
Read the match rate, not the success message
AppsFlyer shows the event on the raw data export with its attributed media source. Check the raw export, not the aggregate dashboard, and confirm the event carries a device identifier rather than landing as organic.
Mailgun → AppsFlyer · prove
How it gets proven — Mailgun → AppsFlyer
Source of truth
Your application's own record of what triggered the send, joined to the order.
- The AppsFlyer device identifier, appsflyer_id confirmed present on a live message.
- In-app revenue events reconciled per transaction against your billing system, with the organic share stated rather than assumed away.
- Orders reconciled against imported conversions, with the send inventory documented.
Mailgun → AppsFlyer · free audit
What we check in the free audit
- Count messages carrying the AppsFlyer device identifier, appsflyer_id
- Follow one real conversion end to end
- Inventory every code path that triggers a send
- Check what share of your revenue happens in the app at all
- Read the match rate, not the success message
Checked against
Your application's own record of what triggered the send, joined to the order.
Free30 minutesNo obligation
Mailgun → AppsFlyer · when not to buy
When you don't need this — Mailgun → AppsFlyer
- Measure identifier coverage yourself first — pull your last hundred messages and count how many carry the AppsFlyer device identifier, appsflyer_id.
- Deliverability monitoring is the right use of Mailgun's data. Attribution belongs at the order.
- If you have no mobile app, this is not a destination for you. If you have one but sell mostly on the web, send web conversions to your ad platforms directly and use AppsFlyer only for install and in-app events.
Mailgun → AppsFlyer · what we deliver
What gets built — Mailgun → AppsFlyer
Identifier capture into Mailgun
Record the trigger reason on the message in your own system and attribute at the order.
Event source: your order system
Send orders. Use Mailgun events for deliverability monitoring only.
Dispatch to AppsFlyer
The AppsFlyer server-to-server events API, posted from your billing system with the device identifier and revenue.
Reversals where they exist
Refunds reverse at the order.
Written guarantee
95%+ tracking accuracy
Measured against Your application's own record of what triggered the send, joined to the order.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Mailgun → AppsFlyer questions, answered
Mailgun's click tracking rewrites the link to its tracking domain, which is not associated with your app, so iOS treats it as a web link. Disable click tracking on those messages or configure the tracking domain for Universal Links.
Yes, if the email links are OneLinks with campaign parameters and the deep link survives Mailgun's redirect. The attribution comes from the OneLink, not from Mailgun data.
Almost always because the AppsFlyer device identifier, appsflyer_id never reached the Mailgun message. No session, no click, and the trigger conditions are buried in application code rather than in a campaign tool. Measure coverage before debugging the dispatch.
AppsFlyer assigns its own device ID and matches installs to clicks through referrer data on Android and Apple's frameworks on iOS. There is no durable cross-device identifier. On iOS without ATT consent, attribution falls back to SKAdNetwork, which returns aggregated conversion values on a delay with no user-level detail at all — so a share of your installs will be attributable only in aggregate, permanently.
Your order system. Send orders. Use Mailgun events for deliverability monitoring only.
AppsFlyer shows the event on the raw data export with its attributed media source. Check the raw export, not the aggregate dashboard, and confirm the event carries a device identifier rather than landing as organic.
More on Mailgun → AppsFlyer
- Stripe → AppsFlyerConnecting Stripe to AppsFlyer
- PayPal → AppsFlyerConnecting PayPal to AppsFlyer
- Shopify → AppsFlyerConnecting Shopify to AppsFlyer
RELATED GUIDES
Where Mailgun → AppsFlyer fits in the rest of your tracking
- SendGrid → AppsFlyerConnecting SendGrid to AppsFlyer
- Resend → AppsFlyerConnecting Resend to AppsFlyer
- Postmark → AppsFlyerConnecting Postmark to AppsFlyer
- SaaSConversion tracking for SaaS, from signup through to the payment that matters
- Postmark → BranchConnecting Postmark to Branch
- Resend → BranchConnecting Resend to Branch
- SendGrid → BranchConnecting SendGrid to Branch
Free · 30 min
Get Mailgun and AppsFlyer joined properly
Free30 minutesNo obligation
