Skip to main content
Mailgun → AmplitudeIntegration guide

Connecting Mailgun to Amplitude

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. Amplitude is built around behavioural cohorts, which makes the identity resolution and the event taxonomy load-bearing in a way they never are for an ad pixel. The join between them succeeds or fails on one thing: whether the user ID and device ID pair reaches the Mailgun message before the conversion happens, because Amplitude can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Mailgun events in Amplitude: which sends move activation

Attach the Amplitude user ID and a trigger reason, such as trial day 3, as Mailgun custom variables on every send, so delivered, clicked and failed webhooks can be posted to the right Amplitude user and cohorts built per send type. Treat opens as weak, use Mailgun's event ID as insert_id, and keep revenue on your own order events.

Amplitude is where Mailgun data can matter beyond deliverability: did users who got the onboarding sequence activate faster than those whose email bounced? That only works if each Mailgun event can be tied to an Amplitude user. Attach the Amplitude user ID and a trigger reason to every message as Mailgun custom variables; they come back on every webhook for that message, so delivered, clicked and failed events can be posted to Amplitude on the right user.

The trigger reason is the part most teams skip and the part that makes this worth doing. Sends are triggered in code, so the event in Amplitude should say which code path sent it, such as trial day 3, password reset or setup abandoned, not just Email Delivered. Then cohorts can be built per send type, and you get what is often the first inventory anyone has made of what the application emails.

Treat opens as weak. Apple Mail Privacy Protection preloads tracking pixels, so opens show up for messages nobody read, and a cohort built on opens is inflated by every Apple Mail user. Clicks and permanent failures are the usable signals. Use Mailgun's event ID as insert_id so webhook retries don't duplicate, and keep revenue on order events from your own system; an email click is never a revenue event.

Mailgun → Amplitude · what breaks

Why this join usually fails — Mailgun → Amplitude

  1. 01

    The user ID and device ID pair never reaches Mailgun

    No session, no click, and the trigger conditions are buried in application code rather than in a campaign tool.

  2. 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.

  3. 03

    Revenue events that carry no revenue

    Amplitude will happily accept a purchase event with no price field. The event count looks correct, the funnel looks correct, and the revenue reporting stays at zero — which people usually discover a quarter later when someone asks what a cohort is worth.

  4. 04

    Nothing reconciles afterwards

    Amplitude shows the event in the user's activity stream with its properties expanded. Read the properties, because an event that arrives without its revenue fields still looks like a success.

Mailgun → Amplitude · the fix

What working looks like — Mailgun → Amplitude

  • The user ID and device ID pair on every message

  • Conversions arriving in Amplitude

    The event lands on the user, joins their behavioural history, and becomes available for cohorts, funnels and retention.

  • Reconciled against the source

Mailgun → Amplitude · architecture

How Mailgun and Amplitude actually connect

  1. 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. 2

    Amplitude needs a click to match

    Amplitude needs a device or user identifier, an event type and its properties. Revenue events need the price and quantity fields specifically, or the revenue reporting stays empty while events flow normally.

  3. 3

    The identifier is the bridge

    The user ID and device ID pair, captured at the visit and carried into the Mailgun message.

  4. 4

    The event source decides reliability

    Send orders. Use Mailgun events for deliverability monitoring only.

  5. 5

    Deduplication at the destination

    Amplitude deduplicates on insert_id. Omit it and a retried batch is counted twice, which shows up as a phantom spike that someone will eventually build a hypothesis on.

Mailgun → Amplitude · normal or broken

Working vs. broken, side by side — Mailgun → Amplitude

Normal, not a fault

  • The user ID and device ID pair present on the message

  • Sent from your order system

  • Deduplicated correctly

    Amplitude deduplicates on insert_id. Omit it and a retried batch is counted twice, which shows up as a phantom spike that someone will eventually build a hypothesis on.

  • Reconciles with the source

Actually broken

  • The user ID and device ID pair 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

    Amplitude will happily accept a purchase event with no price field. The event count looks correct, the funnel looks correct, and the revenue reporting stays at zero — which people usually discover a quarter later when someone asks what a cohort is worth.

  • Nobody has reconciled it

Mailgun → Amplitude · diagnose

Diagnostic order — Mailgun → Amplitude

  1. 01

    Count messages carrying the user ID and device ID pair

  2. 02

    Follow one real conversion end to end

  3. 03

    Inventory every code path that triggers a send

    Usually the first time anyone has, and it frequently finds sends nobody remembers building.

  4. 04

    Check a purchase event for the price and quantity fields specifically

    Not whether the event arrived — whether the revenue fields are populated, in the exact names Amplitude expects.

  5. 05

    Read the match rate, not the success message

    Amplitude shows the event in the user's activity stream with its properties expanded. Read the properties, because an event that arrives without its revenue fields still looks like a success.

Mailgun → Amplitude · prove

How it gets proven — Mailgun → Amplitude

Source of truth

Your application's own record of what triggered the send, joined to the order.

  • The user ID and device ID pair confirmed present on a live message.
  • Revenue reconciled per transaction against your billing system, with identity merge behaviour verified across signup.
  • Orders reconciled against imported conversions, with the send inventory documented.

Mailgun → Amplitude · free audit

What we check in the free audit

  • Count messages carrying the user ID and device ID pair
  • Follow one real conversion end to end
  • Inventory every code path that triggers a send
  • Check a purchase event for the price and quantity fields specifically
  • Read the match rate, not the success message

Checked against

Your application's own record of what triggered the send, joined to the order.

Get my free conversion tracking audit

Free30 minutesNo obligation

Mailgun → Amplitude · when not to buy

When you don't need this — Mailgun → Amplitude

  • Measure identifier coverage yourself first — pull your last hundred messages and count how many carry the user ID and device ID pair.
  • Deliverability monitoring is the right use of Mailgun's data. Attribution belongs at the order.
  • If nobody is building cohorts or retention analysis, this is a large amount of instrumentation for reporting a dashboard already gives you.

Mailgun → Amplitude · what we deliver

What gets built — Mailgun → Amplitude

  • 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 Amplitude

    The Amplitude HTTP V2 API, posted server-side with the identity, event type and 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.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Mailgun → Amplitude questions, answered

Point Mailgun webhooks at an endpoint you run, read the user ID you attached as a custom variable, and post the event to Amplitude's HTTP API with that user ID. Without the custom variable you have only an email address, which may not match your Amplitude user.

Free · 30 min

Get Mailgun and Amplitude joined properly

Free30 minutesNo obligation