Salesforce v2 Cloud Mode Integration

Send events to Salesforce using RudderStack cloud mode.

RudderStack lets you identify your leads in Salesforce without having to use the REST APIs.

Find the open source transformer code for this destination in the GitHub repository.

Identify

You can use the identify call to create or update leads in Salesforce.

The following code snippet demonstrates a sample identify call:

rudderanalytics.identify('1hKOmRA4GRlm', {
  name: 'Alex Keener',
  title: 'Mr.',
  email: 'alex@example.com',
  company: 'Google Inc.',
  phone: '+1-202-555-0146',
  rating: 'Hot',
  city: 'New Orleans',
  postalCode: '90002',
  country: 'US',
  street: 'Blue Gum Street',
  state: 'LA'
});

When you make an identify call, RudderStack checks if the lead already exists using the email property. If yes, the lead/contact is updated with the traits passed in the identify event. If not, RudderStack creates a new lead in Salesforce.

Note that:

  • You don’t require a userId to create a lead in Salesforce.
  • When you make an identify call with a set of user traits, RudderStack updates the appropriate record in Salesforce depending on whether it is a lead or a contact using its lead or contact ID.

Update custom fields in Salesforce

To update custom fields in Salesforce using RudderStack, make sure that you first create those fields in Salesforce before sending the data through RudderStack. See the Salesforce Help guide for more information.

As the Salesforce Leads API requireslastName and company to be present, absence of either of these fields results in RudderStack automatically appending the 'n/a' to both the fields - even if you have specified them in some previous request.

For example, if you want to collect a custom trait in RudderStack named newProp, create a field label named newProp. This will generate an API name as newProp__c. RudderStack automatically appends the __c to any custom trait.

warning

Make sure the casing is consistent.

For example, if you create the custom fields in camel case, then you must send the traits to RudderStack in camel case only.

Update Salesforce objects

You can create or update any Salesforce object using the identify event. To specify the object type, follow the below schema.

RudderStack looks for the key externalId under context and determines the Salesforce object type by removing the part Salesforce- from the field type. Further, it makes a PATCH request if there is an id present in the request to update the record. Otherwise, it creates a new record in Salesforce.

warning

Note that:

  • You cannot send an id property when creating new records as it will lead to an API failure.
  • When creating new records, only provide the type: "Salesforce-Contact" portion of the externalId object.

You can pass multiple object types in a single request and RudderStack creates that many requests to Salesforce, as shown:

rudderanalytics.identify('123456',
    {
      FirstName: "John",
      LastName: "Gibbs",
      Email: "john@peterson.com"
    },
    {
      externalId: [
        {
          type: "Salesforce-Contact",
          id: "sf-contact-id"
        }
      ]
    });

In the example above, RudderStack updates the Contact object in Salesforce with id as sf-contact-id and sends the traits object to Salesforce.

info
By default, RudderStack creates a Lead object in Salesforce and maps the traits to it. RudderStack does not modify the traits for other objects - they are sent to Salesforce as is.

Supported mappings

RudderStack supports and maps the event properties to several standard fields in Salesforce, as listed in the following table:

RudderStack propertySalesforce field
address.accuracy / accuracyAccuracy
company.annualRevenueAnnualRevenue
address.city / cityCity
company.name / companyCompany
address.country / countryCountry
address.countryCode / countryCodeCountryCode
convertedAccountIdConvertedAccountId
convertedContactIdConvertedContactId
convertedDateConvertedDate
convertedOpportunityIdConvertedOpportunityId
createdByIdCreatedById
createdAt / createddateCreatedDate
descriptionDescription
emailEmail
emailBouncedDateEmailBouncedDate
emailBouncedReasonEmailBouncedReason
firstNameFirstName
geocodeAccuracyGeocodeAccuracy
idId
company.industryIndustry
individualIdIndividualId
isConvertedIsConverted
isDeletedIsDeleted
isUnreadByOwnerIsUnreadByOwner
jigsawJigsaw
jigsawContactIdJigsawContactId
lastActivityDateLastActivityDate
lastModifiedByIdLastModifiedById
lastModifiedDateLastModifiedDate
lastNameLastName
lastReferencedDateLastReferencedDate
lastViewedDateLastViewedDate
address.latitude / latitudeLatitude
LeadSourceLeadSource
address.longitude / longitudeLongitude
masterRecordIdMasterRecordId
nameName
company.employee_countNumberOfEmployees
ownerIdOwnerId
phonePhone
photoUrlPhotoUrl
address.postalCode / postalCodePostalCode
ratingRating
salutationSalutation
address.state / stateState
address.stateCode / stateCodeStateCode
statusStatus
address.street / streetStreet
systemModstampSystemModstamp
titleTitle
websiteWebsite


Questions? Contact us by email or on Slack