Send engagement data from Journeys back to Salesforce

Engagement data is how you engage with your contacts and how your contacts respond—like when you send an email to a contact and whether they open it, click a link, and so on. We sometimes refer to engagement data as message metrics. You can send this data back to Salesforce to update their last activity date and determine whether your contacts are active, at risk to churn, and so on.

 Want to update Salesforce data for other reasons?

If you want to send other data to Salesforce, and you’re not particularly interested in engagement data, set up your Salesforce destination and go on to the next page. There, we’ll show you how to use webhooks to update Salesforce records as a part of a campaignA series of actions that you perform for each person who matches criteria. Campaigns typically send people a series of messages, but you can also use campaigns to send webhooks, update attributes, etc.

How it works

You’ll set up a Salesforce destination. It’s a bit like the Salesforce source you set up before, but data flows back into Salesforce. Then you’ll set up an actionThe source event and data that triggers an API call to your destination. For example, an incoming identify event from your sources adds or updates a person in our Journeys destination. to handle engagement data. We’ll show you how to set up your first action, and then you can add as many as you need to handle different engagement events.

1. Set up your Salesforce destination

Your Salesforce destination is where we’ll send your engagement data.

  1. Go to the tab and click Destinations.

  2. Find the Salesforce destination and click Next: Choose Sources.

    pick your salesforce destination
    pick your salesforce destination

  3. Pick Journeys Message Metrics and click Next: Connect Salesforce.

  4. Click Connect Salesforce and enter your Salesforce credentials. This authorizes us to send data back to your Salesforce instance. Now the connections page shows Salesforce and Journeys as both sources and destinations. This lets your data go from Salesforce to Journeys and back to Salesforce.

    The Journeys metriccs source is connected to a Salesforce destination
    The Journeys metriccs source is connected to a Salesforce destination

But you’re not done yet! While you’re connected to Salesforce, you’re not sending data there yet. You still need to set up an action to tell us what data to send to Salesforce.

2. Set up a Salesforce action

Setting up an action can be a little daunting because there are so many settings. The process below will tell you what settings to change. For everything else, you can leave default settings.

  1. Now go to your Salesforce destination on the right of the Connections page, and go to the Actions tab. Click Add Action.

  2. For the Action, select Contact—this is who or what you want to update in Salesforce when you send message metrics (or webhooks) to Salesforce.

  3. For the Trigger, set Type is Track.

    A track call represents an event—something a contact did. Message metrics, and much of the data you can send with webhooks, are track events.

    An action with the type set to contact and the trigger set to type equals track.
    An action with the type set to contact and the trigger set to type equals track.

  4. Under Data Structure, set the first box to Update. This tells Salesforce to update a record when a contact does something in a campaign. You don’t want to create contacts based on engagement information.

    You might use the Create operation if you use webhooks or you use a form integration to capture leads from a website. But those are both much more advanced use cases!

  5. In the Record Matchers field: click Add Key/Value, type in contact_id on the left and select $.userId on the right.

    This tells Salesforce to match a person’s id in to the contact ID in Salesforce. You can also match on things like the email address. But, if you want to match on other values, you’ll want to take a look at Salesforce’s API docs first.

    Set contact_id to $.userId
    Set contact_id to $.userId

     Use $.userId not $

    If you map data to $, you’ll get an error: Undefined Traits when using update operation.

  6. At the bottom of the page, click Add Key/Value. Enter LastActivityDate on the left and $.timestamp.

    This tells Salesforce to update the Last Activity Date field in Salesforce with the timestamp of the last activity in

    If you’re an advanced user, you can pass additional fields, like IsEmailBounced or EmailBouncedDate if you want to capture other engagement data. But, for now, we’ll keep it simple.

    An action showing the timestamp and beta participant fields that will send to Salesforce.
    An action showing the timestamp and beta participant fields that will send to Salesforce.

  7. Leave the remaining fields as their defaults and click Save Action.

Now we’ll update the Last Activity Date in Salesforce whenever you send a message or your audience responds to the message. You can either set up other actions—like using bounced events to update the Is Email Bounced field, or the Email Opt Out field when you get an Email Unsubscribed event.

Move on to the next task if you want to update Salesforce records based on activity in a campaign.

Undefined traits when using update operation error

This error typically occurs if you try to match records in Salesforce to $ instead of $.userId. The $ property doesn’t contain any data (it’s undefined), so Salesforce won’t be able to update a record.

Make sure that your Salesforce actions are set up to use $.userId instead of $ See Set up a Salesforce action above for help updating your actions.

Set contact_id to $.userId
Set contact_id to $.userId
Copied to clipboard!
Is this page helpful?
Chat with AI