Connecting Mailgun to X Ads
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. X is a conversation platform where a large share of engagement is discussion rather than intent, which makes the gap between engagement metrics and conversions unusually wide. The join between them succeeds or fails on one thing: whether the twclid click identifier reaches the Mailgun message before the conversion happens, because X Ads can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
X Ads and Mailgun receipts: stop order links re-firing purchases
Send the X purchase once, server-side from the order, with the order ID as conversion ID and the twclid stored at checkout, matching any confirmation-page pixel. Click the order link in a real Mailgun confirmation to check it doesn't re-fire the pixel. Tag email links with UTMs so repeat orders from Mailgun reminders aren't credited to X.
Mailgun doesn't send anything X can use; X conversions come from your order system. Where the two collide is the order confirmation email. Your application sends it through Mailgun with a link to view the order, and if that link opens a page where the X pixel fires a purchase, every customer who checks their order status counts again, from whatever browser the email app opens.
X volumes are often small enough that a few re-fired purchases read as a good week, so check it directly. Click the order link in a real Mailgun confirmation email and watch whether a purchase event fires. The fix is to send the X purchase once, server-side, from the order, with the order ID as the conversion ID and the twclid stored at checkout. If you keep the pixel on the confirmation page, give it the same ID so X can deduplicate.
The other thing to keep apart is credit. Customers who arrive from an email link carry no twclid, and a later repeat purchase from a Mailgun reminder shouldn't go to X as a new conversion unless X drove that session. Tag email links with UTMs naming the send type, so your own reporting shows which repeat orders came from email rather than from X.
Mailgun → X Ads · what breaks
Why this join usually fails — Mailgun → X Ads
- 01
The twclid click identifier 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
Engagement mistaken for intent
A post can be quoted, argued with and shared widely by people with no interest in buying anything. Optimising toward engagement on this platform reliably finds an audience that will never convert, and the engagement numbers look excellent throughout.
- 04
Nothing reconciles afterwards
Read the delivered and matched counts in X's reporting rather than assuming a 200 response means the event was usable.
Mailgun → X Ads · the fix
What working looks like — Mailgun → X Ads
The twclid click identifier on every message
Conversions arriving in X Ads
The conversion is matched to a click or an engagement and becomes available for optimisation and reporting.
Reconciled against the source
Mailgun → X Ads · architecture
How Mailgun and X Ads 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
X Ads needs a click to match
An event X recognises, a conversion identifier for deduplication, hashed customer information, and the click identifier where you have it.
- 3
The identifier is the bridge
The twclid click identifier, 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
X deduplicates browser and server events on a shared conversion ID. Send both without pairing them and every conversion counts twice — worth testing deliberately, because X volumes are often small enough that a doubling reads as a good week.
Mailgun → X Ads · normal or broken
Working vs. broken, side by side — Mailgun → X Ads
Normal, not a fault
The twclid click identifier present on the message
Sent from your order system
Deduplicated correctly
X deduplicates browser and server events on a shared conversion ID. Send both without pairing them and every conversion counts twice — worth testing deliberately, because X volumes are often small enough that a doubling reads as a good week.
Reconciles with the source
Actually broken
The twclid click identifier 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
A post can be quoted, argued with and shared widely by people with no interest in buying anything. Optimising toward engagement on this platform reliably finds an audience that will never convert, and the engagement numbers look excellent throughout.
Nobody has reconciled it
Mailgun → X Ads · diagnose
Diagnostic order — Mailgun → X Ads
- 01
Count messages carrying the twclid click identifier
- 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
Compare engagement rate against conversion rate by campaign
On X the two frequently move in opposite directions, and that divergence is the finding rather than a measurement fault.
- 05
Read the match rate, not the success message
Read the delivered and matched counts in X's reporting rather than assuming a 200 response means the event was usable.
Mailgun → X Ads · prove
How it gets proven — Mailgun → X Ads
Source of truth
Your application's own record of what triggered the send, joined to the order.
- The twclid click identifier confirmed present on a live message.
- Conversions reconciled per order against imported figures, with deduplication verified on a live test.
- Orders reconciled against imported conversions, with the send inventory documented.
Mailgun → X Ads · free audit
What we check in the free audit
- Count messages carrying the twclid click identifier
- Follow one real conversion end to end
- Inventory every code path that triggers a send
- Compare engagement rate against conversion rate by campaign
- 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 → X Ads · when not to buy
When you don't need this — Mailgun → X Ads
- Measure identifier coverage yourself first — pull your last hundred messages and count how many carry the twclid click identifier.
- Deliverability monitoring is the right use of Mailgun's data. Attribution belongs at the order.
- If X is a brand and community channel for you rather than a performance one, measure it that way and do not force a conversion pipeline onto it.
Mailgun → X Ads · what we deliver
What gets built — Mailgun → X Ads
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 X Ads
The X Conversions API, posted server-side with the click identifier and hashed customer data.
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 → X Ads questions, answered
Common causes are pixel and server events without a shared conversion ID, and order-status pages linked from confirmation emails that fire the purchase again. Check both with a real order.
Only if X drove that session, which you know from a twclid stored on the order. Otherwise X learns to take credit for customers your email brought back.
Almost always because the twclid click identifier 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.
X appends twclid to the landing URL and the pixel stores it. It behaves like other click identifiers, with the usual caveat that a large share of X traffic arrives through the in-app browser, where storage is partitioned and short-lived.
Your order system. Send orders. Use Mailgun events for deliverability monitoring only.
Read the delivered and matched counts in X's reporting rather than assuming a 200 response means the event was usable.
More on Mailgun → X Ads
- Mailgun → Google AdsConnecting Mailgun to Google Ads
- Mailgun → Microsoft AdsConnecting Mailgun to Microsoft Ads
- Mailgun → Apple Search AdsConnecting Mailgun to Apple Search Ads
RELATED GUIDES
Where Mailgun → X Ads fits in the rest of your tracking
- X Ads · EcommerceX Ads conversion tracking for ecommerce brands
- X Ads · SaaSX Ads conversion tracking for SaaS companies
- X Ads × SubscriptionsHow to reconcile X Ads against your billing system
- X Ads · Signup → activationHow to track signup to product activation for X Ads
- Postmark → X AdsConnecting Postmark to X Ads
- Mailgun → LinkedInConnecting Mailgun to LinkedIn Ads
- SaaSConversion tracking for SaaS, from signup through to the payment that matters
- SendGrid → X AdsConnecting SendGrid to X Ads
Free · 30 min
Get Mailgun and X Ads joined properly
Free30 minutesNo obligation
