Contact Us

May 4, 2026

May 8, 2026 12:49 am

Populate CampaignMemberId & CampaignId on Individual Email Results via MC Connect 2026: The Complete Pattern

Share with

Individual Email Results in Salesforce CRM are the bridge between Marketing Cloud sends and the Contact or Lead records that sales teams rely on daily. They record what was sent, when it was opened, and whether it was clicked — all visible right on the Contact page without needing to log into SFMC.

The gap that most teams run into: IER records do not automatically carry CampaignMemberId or CampaignId when a send originates from a Journey Builder campaign injection. Both fields exist on the IER object — CampaignMemberId is even a standard field — but they stay empty unless you explicitly build the plumbing to carry those values from the moment of send through to the CRM record update.

This guide covers the exact pattern that works: capture the values at send time using the Send Log, join the IER data view against the Send Log with the correct key combination, and update the IER records in CRM via a Journey Object Activity. We have implemented this for clients who needed their sales teams to be able to filter and report on email activity tied to specific Salesforce campaigns directly from CRM.


Salesforce CRM Individual Email Results — tracking Marketing Cloud send data on Contact and Lead records

Individual Email Results on a Salesforce Contact — CampaignMemberId and CampaignId linking each send back to the originating Campaign.

Understanding Why the Fields Do Not Populate Automatically

When Marketing Cloud Connect creates an IER record in Salesforce after a Journey Builder send, it uses the data available in SFMC’s tracking layer. That layer knows about the send — the email, the subscriber, the job — but it does not inherently know which Salesforce Campaign or Campaign Member triggered the journey entry. That context exists in your Journey entry Data Extension, not in the tracking data views.

The IER object in Salesforce has these relevant fields:

Field Type Populates Automatically? Notes
CampaignMemberId Lookup (CampaignMember) Manual only Standard field. Never populated by MC Connect automatically for Journey sends. Requires the pattern in this guide.
CampaignId Lookup (Campaign) Manual only Must be created as a custom field on IER. Not standard. Must be added to IER object in CRM setup.
ContactId / LeadId Lookup Auto via MC Connect Populated automatically when the 18-digit Contact/Lead ID is used as SubscriberKey.
JobId, BatchId, ListId Text Auto via MC Connect These are the join keys you use to match IER records to Send Log records.
CampaignId must be a custom field. Before starting, add a custom CampaignId__c lookup field to the Individual Email Results object in Salesforce CRM pointing to the Campaign object. Without this, the Journey Object Activity has nowhere to write the Campaign ID value.

The Four-Part Pattern

The implementation runs across four components that must be set up in sequence. Each one hands off context to the next — if any link in the chain is missing, the values will not reach the IER record in CRM.

1

Add CampaignMemberId and CampaignId to the Send Log

The Send Log is a special Data Extension that captures metadata about every send at the moment the email is prepared. Its power is that any AMPscript variable or Data Extension column that shares the name of a Send Log field gets written automatically at send time.

Add two custom fields to your Send Log DE:

Field Name Type Length Note
CampaignMemberId Text 18 Matches the Salesforce CampaignMember ID (18-char)
CampaignId Text 18 Matches the Salesforce Campaign ID (18-char)
SubscriberKey Text 254 Add if not already present — needed for the SQL join

All Send Log fields must be nullable with no primary key. If your Send Log does not exist yet, create it from the template in the Data Extension creation flow under “Create From Template” and select SendLog.

2

Capture the Values via AMPscript in the Email

Add a small AMPscript block to the email body — a Code Snippet content block added to the footer template works well so it applies consistently across all campaign emails without needing to edit each one individually. The script sets variables that match the Send Log field names, which triggers automatic population at send time.

Your Journey entry Data Extension must contain CampaignMemberId and CampaignId columns populated with the correct 18-digit Salesforce IDs before the Journey fires. If you are using a Salesforce Data Entry Event with Campaign Members as the source, these fields are available automatically in the entry DE.

Email AMPscript — Send Log population block (add to footer template)

%%[

/* These variable names match the Send Log field names exactly.
   SFMC automatically writes their values to the Send Log at send time.
   No output is needed — this block runs silently. */

VAR @CampaignMemberId, @CampaignId

/* Pull values from the Journey entry Data Extension */
SET @CampaignMemberId = AttributeValue("CampaignMemberId")
SET @CampaignId       = AttributeValue("CampaignId")

]%%
Test the Send Log population before building the rest of the pattern. After adding this block and sending a test email, check the Send Log DE and confirm the CampaignMemberId and CampaignId columns have values for your test record. If they are empty, the variable names do not match the Send Log field names exactly — field names are case-sensitive. Fix this before moving on.

3

SQL Query to Join Send Log Against IER and Create the Update DE

Once the Send Log is capturing the Campaign values, a daily SQL query joins the Send Log against the IER data view using the correct compound key: JobId, BatchId, ListId, and SubscriberKey. All four must match — using only SubscriberKey will cause incorrect or duplicate matches across different sends.

The query writes results to a staging DE called Update_IER_DE which the Journey will use as its entry source.

Automation Studio SQL — Join Send Log to IER for update staging

/* Joins the Send Log (with captured Campaign values) to the IER data view.
   The four-column join key is critical — using SubscriberKey alone will
   create incorrect matches across multiple campaign sends to the same contact.
   Run daily. Action: Overwrite on Update_IER_DE. */

SELECT
    sl.SubscriberKey,
    sl.CampaignMemberId,
    sl.CampaignId,
    ier.ID              AS IER_MergeID,    /* This is the unique IER record ID in Salesforce */
    sl.JobID,
    sl.BatchID,
    sl.ListID,
    sl.EmailAddress

FROM
    SendLog_DE          sl     /* Replace with your Send Log DE name */

JOIN
    _IndividualEmailResult  ier

    ON  sl.JobID         = ier.JobID
    AND sl.BatchID       = ier.BatchID
    AND sl.ListID        = ier.ListID
    AND sl.SubscriberKey = ier.SubscriberKey    /* All four required */

WHERE
    sl.CampaignMemberId IS NOT NULL
    AND sl.CampaignId   IS NOT NULL
    AND ier.ID          IS NOT NULL    /* Ensures IER record exists in CRM */
    AND sl.LogDate      >= DATEADD(day, -1, GETDATE())  /* Incremental daily run */

The Update_IER_DE staging DE should be sendable, with IER_MergeID as the primary key. The Journey Builder Object Activity will use this field to find the correct IER record in Salesforce and update it.


SFMC Automation Studio SQL Query Activity joining Send Log to IER data view

Automation Studio SQL Query Activity — the four-column join on JobID, BatchID, ListID, and SubscriberKey is what correctly links each Send Log entry to its corresponding IER record in Salesforce.

4

Journey Builder Object Activity to Update IER Records in CRM

The final step uses a Journey Builder Object Activity targeting the Individual Email Results object. Configure it as Find and Update, matching on IER_MergeID to the IER record’s ID field. Map CampaignMemberId and CampaignId__c from the journey DE to the corresponding IER fields.

Set the Journey entry source to Update_IER_DE, Contact Evaluation to Evaluate All Records, and Re-entry to Always. The Journey should be triggered from within the same Automation Studio automation immediately after the SQL query completes.

IER_MergeID is the critical match field. The MergeID on the IER object is Salesforce’s internal unique identifier for that specific IER record — it is distinct from the ContactId or SubscriberKey. Without matching on MergeID, the Object Activity cannot reliably find the right record to update when a contact has multiple IER records across different sends.

Setup Checklist

  • Create CampaignId__c as a custom lookup field on the Individual Email Results object in Salesforce CRM pointing to the Campaign object.
  • Add CampaignMemberId, CampaignId, and SubscriberKey as nullable text fields to your Send Log DE before the next send.
  • Add the AMPscript code block to your email template footer — or a shared Code Snippet content block used across all campaign emails.
  • After the first test send, verify the Send Log DE has values in both Campaign columns before building the SQL query.
  • The SQL JOIN must use all four keys: JobID, BatchID, ListID, and SubscriberKey. Using only SubscriberKey creates incorrect cross-send matches.
  • The Update_IER_DE staging DE must be sendable with IER_MergeID as the primary key.
  • Chain the SQL Query Activity and Journey in the same Automation Studio automation so timing is guaranteed.
  • After the first full run, spot-check five IER records in Salesforce CRM and confirm both CampaignMemberId and CampaignId__c are populated with the correct IDs.

Frequently Asked Questions

What if my Journey entry source is a Data Extension rather than a Salesforce Data Entry Event?

The pattern works the same way. The key requirement is that your entry DE must contain CampaignMemberId and CampaignId columns populated with the correct 18-digit Salesforce IDs before the Journey fires. If you are using a custom sendable DE as the entry source, add those fields to the DE and populate them via your upstream automation or SQL before the Journey runs. If you are using a Salesforce Data Entry Event with Campaign Members as the source, the CampaignMemberId is available automatically in the entry DE.

The Send Log fields are null even though the AMPscript block is in the email. What is wrong?

The most common cause is a field name mismatch. Send Log field names are case-sensitive and must exactly match the AMPscript variable names. Check for extra spaces, different capitalisation, or underscores. The second most common cause is that the entry DE column names do not match what AttributeValue() is looking for — if the entry DE has Campaign_Member_Id but the AMPscript reads CampaignMemberId, the variable will be empty. You can test by adding %%=v(@CampaignMemberId)=%% to the email body temporarily to see what value the variable holds at send time.

How long does it take for IER records to appear in Salesforce after a send?

MC Connect syncs tracking data to Salesforce hourly by default. The IER record itself is created during the first sync after the send. If you need it faster, you can click “Request Tracking Immediately” on the Email Send record in Salesforce. For the Campaign ID and CampaignMemberId update, the Journey Object Activity runs separately after your daily automation completes — so there is typically a window of several hours between when the IER is created and when the Campaign fields are populated. If your use case requires near-real-time Campaign attribution on IERs, the hourly sync constraint is the ceiling — there is no way to make this faster within the native MC Connect architecture.

What types of sends create IER records?

Only Journey Builder sends and Salesforce Sends (from Email Studio using a Salesforce Data Extension) create IER records in CRM. User-Initiated Sends, Triggered Sends, and sends using non-Salesforce Data Extensions do not generate IERs. Additionally, the subscriber must have a Salesforce 18-digit Contact ID or Lead ID as their SFMC SubscriberKey for MC Connect to create the IER correctly. If your SubscriberKey is an email address or a custom key, IER creation will fail silently.

Genetrix Technology · Salesforce Marketing Cloud Partner

Need Marketing Cloud and Salesforce CRM Reporting to Actually Connect?

Campaign attribution, IER population, tracking sync — the gap between what SFMC knows and what CRM shows is a recurring problem for marketing and sales teams. Genetrix builds the integrations that close it.

Talk to Genetrix →

Blogs for the

Business-Savvy!​

Let’s Connect

A 30 min no cost strategy session
with cloud support expert

Let’s Connect

A 30 min no cost strategy session
with cloud support expert