Skip to main content
Mailgun → Marketing CloudIntegration guide

Connecting Mailgun to Salesforce Marketing Cloud

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. Marketing Cloud is a different product from Salesforce CRM with a different identity model, which catches out almost everyone who assumes a contact in one is a contact in the other. The join between them succeeds or fails on one thing: whether the Subscriber Key reaches the Mailgun message before the conversion happens, because Marketing Cloud can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Mailgun email addresses meet Marketing Cloud Subscriber Keys

Attach the Marketing Cloud Subscriber Key to each Mailgun message as a custom variable, then write hard bounces and complaints from the webhook to a Subscriber Key data extension your suppression logic reads; email alone hits the wrong subscriber. Avoid duplicate post-purchase emails from order journeys and Mailgun receipts by consolidating or documenting ownership.

Companies with Marketing Cloud often keep Mailgun for application mail, and the join problem is identity. Mailgun knows an email address; Marketing Cloud tracks people by Subscriber Key, often a CRM Contact ID. One email can belong to several subscriber keys, a lead and a contact for the same person, so syncing anything from Mailgun on email alone updates the wrong subscriber or creates a new one.

Attach the Subscriber Key to each Mailgun message as a custom variable when your application sends it, then use it in the webhook. The events worth syncing are hard bounces and complaints, written to a data extension keyed on Subscriber Key that your suppression logic reads. Marketing Cloud tracks its own bounces for its own sends; it knows nothing about bounces your transactional stream has already found.

Watch the journeys that react to orders. If a journey listens to an order data extension and your application sends a Mailgun receipt from the same order, the customer gets two post-purchase emails, from two systems that do not know about each other. Check whether Marketing Cloud's transactional messaging would let you consolidate receipts, or document in the send inventory which system sends which message.

Mailgun → Marketing Cloud · what breaks

Why this join usually fails — Mailgun → Marketing Cloud

  1. 01

    The Subscriber Key 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

    Two identity models treated as one

    Marketing Cloud's Subscriber Key and CRM's Contact ID are separate concepts, and Contact Builder's configuration decides whether they relate at all. Getting this wrong does not produce an error — it produces a customer who exists twice, receives everything twice, and appears in reporting as two people.

  4. 04

    Nothing reconciles afterwards

    Check the subscriber record and the journey history, not the API response. A successful insert into an unwatched data extension looks identical to a successful one into the right extension.

Mailgun → Marketing Cloud · the fix

What working looks like — Mailgun → Marketing Cloud

  • The Subscriber Key on every message

  • Conversions arriving in Marketing Cloud

    The record lands in the data extension, the journey's entry criteria evaluate on its schedule, and sends follow.

  • Reconciled against the source

Mailgun → Marketing Cloud · architecture

How Mailgun and Marketing Cloud 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

    Salesforce Marketing Cloud needs a click to match

    The Subscriber Key, the data extension the journey listens to, and the fields its decision splits reference. An event landing in the wrong data extension will be stored correctly and trigger nothing.

  3. 3

    The identifier is the bridge

    The Subscriber Key, 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

    Marketing Cloud does not deduplicate journey entries for you. A record inserted twice can enter a journey twice, and because journeys span email, SMS and push the duplicate reaches the customer more than once.

Mailgun → Marketing Cloud · normal or broken

Working vs. broken, side by side — Mailgun → Marketing Cloud

Normal, not a fault

  • The Subscriber Key present on the message

  • Sent from your order system

  • Deduplicated correctly

    Marketing Cloud does not deduplicate journey entries for you. A record inserted twice can enter a journey twice, and because journeys span email, SMS and push the duplicate reaches the customer more than once.

  • Reconciles with the source

Actually broken

  • The Subscriber Key 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 Cloud's Subscriber Key and CRM's Contact ID are separate concepts, and Contact Builder's configuration decides whether they relate at all. Getting this wrong does not produce an error — it produces a customer who exists twice, receives everything twice, and appears in reporting as two people.

  • Nobody has reconciled it

Mailgun → Marketing Cloud · diagnose

Diagnostic order — Mailgun → Marketing Cloud

  1. 01

    Count messages carrying the Subscriber Key

  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

    Confirm what Subscriber Key is actually set to in this org

    Before sending anything. It is a configuration decision made once, often years ago, and every integration built afterwards inherits it.

  5. 05

    Read the match rate, not the success message

    Check the subscriber record and the journey history, not the API response. A successful insert into an unwatched data extension looks identical to a successful one into the right extension.

Mailgun → Marketing Cloud · prove

How it gets proven — Mailgun → Marketing Cloud

Source of truth

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

  • The Subscriber Key confirmed present on a live message.
  • Records confirmed on single subscriber records in the correct data extension, with the triggered journey verified in a non-production business unit first.
  • Orders reconciled against imported conversions, with the send inventory documented.

Mailgun → Marketing Cloud · free audit

What we check in the free audit

  • Count messages carrying the Subscriber Key
  • Follow one real conversion end to end
  • Inventory every code path that triggers a send
  • Confirm what Subscriber Key is actually set to in this org
  • 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 → Marketing Cloud · when not to buy

When you don't need this — Mailgun → Marketing Cloud

  • Measure identifier coverage yourself first — pull your last hundred messages and count how many carry the Subscriber Key.
  • Deliverability monitoring is the right use of Mailgun's data. Attribution belongs at the order.
  • If you are on Salesforce CRM but sending email through a simpler platform, adding Marketing Cloud brings an identity model to reconcile that you currently do not have to think about.

Mailgun → Marketing Cloud · what we deliver

What gets built — Mailgun → Marketing Cloud

  • 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 Marketing Cloud

    A server-side insert into the data extension the journey is configured against, keyed on Subscriber Key.

  • 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 → Marketing Cloud questions, answered

Include the Subscriber Key on each Mailgun message as a custom variable, then write bounces and complaints from the webhook into a data extension keyed on it.

Free · 30 min

Get Mailgun and Marketing Cloud joined properly

Free30 minutesNo obligation