Connecting Mailgun to Mixpanel
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. Mixpanel is a product analytics tool, not an ad platform, which means it has no attribution model of its own and will faithfully report whatever event schema you give it — including a bad one. The join between them succeeds or fails on one thing: whether the distinct_id reaches the Mailgun message before the conversion happens, because Mixpanel can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Mailgun events in Mixpanel without polluting product funnels
Pass the Mixpanel distinct_id as a Mailgun custom variable, then send one Email Event with type, send reason and template as properties, using Mailgun's event ID as $insert_id. Add a permanent delivery failure profile property to exclude unreachable users, and build funnels from clicked sends to product actions. Backfill old logs through the import API with original timestamps.
Mixpanel is where product decisions get made, so Mailgun events going in there need to be few, well named and on the right person. Pass the user's distinct_id as a Mailgun custom variable on each send; it comes back on every webhook for that message, so the event lands on the profile instead of on someone matched by an email address that may have changed.
Send one event, Email Event or similar, with type (delivered, clicked, failed, unsubscribed), send reason and template as properties, rather than a separate event name for every Mailgun webhook. Six new event names per email type is how a Mixpanel project ends up with dozens of near-duplicates nobody can tell apart. Use Mailgun's event ID as $insert_id, because webhooks retry and Mixpanel would otherwise record the delivery twice.
Two Mixpanel uses justify the work. A profile property for permanent delivery failure lets the product team exclude unreachable users when reading any funnel that depends on email. And a funnel from Email Event (clicked, reason trial ending) to the in-product action shows whether that specific send does anything. Backfilling old Mailgun logs is a separate job: older events need Mixpanel's import API with their original timestamps, not the live endpoint.
Mailgun → Mixpanel · what breaks
Why this join usually fails — Mailgun → Mixpanel
- 01
The distinct_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
One event schema, two teams, no agreement
Marketing names an event Purchase, the product team names it purchase_completed, and both are sent. Mixpanel treats them as unrelated, every funnel silently splits, and two teams spend a quarter arguing about which number is right when both are.
- 04
Nothing reconciles afterwards
Mixpanel shows events in the live view within moments. Check that the distinct_id matches the signed-in user rather than a lingering anonymous ID, because that is the failure that quietly breaks every cross-signup funnel.
Mailgun → Mixpanel · the fix
What working looks like — Mailgun → Mixpanel
The distinct_id on every message
Conversions arriving in Mixpanel
The event lands on the user profile and becomes available in funnels, retention and cohort analysis.
Reconciled against the source
Mailgun → Mixpanel · architecture
How Mailgun and Mixpanel 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
Mixpanel needs a click to match
Mixpanel needs a distinct_id, an event name and its properties. Events without a distinct_id are rejected; events with the wrong one land on a stranger's profile.
- 3
The identifier is the bridge
The distinct_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
Mixpanel deduplicates on $insert_id within a time window. Without it, a retried server request creates a second event, and because Mixpanel is where product decisions get made, that inflation ends up in a roadmap rather than in an ad report.
Mailgun → Mixpanel · normal or broken
Working vs. broken, side by side — Mailgun → Mixpanel
Normal, not a fault
The distinct_id present on the message
Sent from your order system
Deduplicated correctly
Mixpanel deduplicates on $insert_id within a time window. Without it, a retried server request creates a second event, and because Mixpanel is where product decisions get made, that inflation ends up in a roadmap rather than in an ad report.
Reconciles with the source
Actually broken
The distinct_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
Marketing names an event Purchase, the product team names it purchase_completed, and both are sent. Mixpanel treats them as unrelated, every funnel silently splits, and two teams spend a quarter arguing about which number is right when both are.
Nobody has reconciled it
Mailgun → Mixpanel · diagnose
Diagnostic order — Mailgun → Mixpanel
- 01
Count messages carrying the distinct_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
List every event name in the project and look for near-duplicates
Case differences, tense differences and synonyms are the usual finding, and they are cheap to fix before a year of data is built on them.
- 05
Read the match rate, not the success message
Mixpanel shows events in the live view within moments. Check that the distinct_id matches the signed-in user rather than a lingering anonymous ID, because that is the failure that quietly breaks every cross-signup funnel.
Mailgun → Mixpanel · prove
How it gets proven — Mailgun → Mixpanel
Source of truth
Your application's own record of what triggered the send, joined to the order.
- The distinct_id confirmed present on a live message.
- Purchase events reconciled per transaction against your billing system, with identity aliasing verified across the signup boundary.
- Orders reconciled against imported conversions, with the send inventory documented.
Mailgun → Mixpanel · free audit
What we check in the free audit
- Count messages carrying the distinct_id
- Follow one real conversion end to end
- Inventory every code path that triggers a send
- List every event name in the project and look for near-duplicates
- 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 → Mixpanel · when not to buy
When you don't need this — Mailgun → Mixpanel
- Measure identifier coverage yourself first — pull your last hundred messages and count how many carry the distinct_id.
- Deliverability monitoring is the right use of Mailgun's data. Attribution belongs at the order.
- If you already have the same events in a warehouse and nobody is running product analysis on them, adding Mixpanel adds a second source of truth rather than an answer.
Mailgun → Mixpanel · what we deliver
What gets built — Mailgun → Mixpanel
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 Mixpanel
The Mixpanel ingestion API, posted server-side from your backend with the distinct_id and event properties.
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 → Mixpanel questions, answered
Attach the distinct_id as a custom variable when sending, receive Mailgun webhooks on an endpoint you control, and post each event to Mixpanel with that distinct_id and Mailgun's event ID as $insert_id.
Not as a key metric. Some mail clients load tracking pixels automatically, so opens include messages nobody read; clicks and the in-product action afterwards are better.
Almost always because the distinct_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.
Mixpanel identifies people by distinct_id, which starts as an anonymous device value and should be aliased to your own user ID at signup. Getting that alias wrong is the single most common Mixpanel implementation failure: the anonymous pre-signup activity and the identified user become two separate people, and every funnel that crosses signup is broken.
Your order system. Send orders. Use Mailgun events for deliverability monitoring only.
Mixpanel shows events in the live view within moments. Check that the distinct_id matches the signed-in user rather than a lingering anonymous ID, because that is the failure that quietly breaks every cross-signup funnel.
More on Mailgun → Mixpanel
- Stripe → MixpanelConnecting Stripe to Mixpanel
- PayPal → MixpanelConnecting PayPal to Mixpanel
- Shopify → MixpanelConnecting Shopify to Mixpanel
RELATED GUIDES
Where Mailgun → Mixpanel fits in the rest of your tracking
- Resend → MixpanelConnecting Resend to Mixpanel
- SendGrid → MixpanelConnecting SendGrid to Mixpanel
- Postmark → MixpanelConnecting Postmark to Mixpanel
- Mailgun → AmplitudeConnecting Mailgun to Amplitude
- Mailgun → GA4Connecting Mailgun to GA4
- SaaSConversion tracking for SaaS, from signup through to the payment that matters
Free · 30 min
Get Mailgun and Mixpanel joined properly
Free30 minutesNo obligation
