Salesforce Marketcloud - XML/JSON (Extension API) - Add Lead

Custom integration that creates/updates contacts directly in a client's Salesforce Marketcloud Extension. This method allows you to keep the lead separate from your main SFMC leads.

Step 1

Credentials

Ask the client to setup their credentials to their console you can provide the following URL with the placeholder replaced

{console}.postclickmarketing.com/Admin/Integration/ExternalServices

 

Within the Custom Category the client needs to create two new entries (suggested labels SFMC API Credentials and SFMC Auth URL).

 

In the first entry (SFMC API Credentials) they place their clientID as username and the clientSecret as Password.

 

In the second entry (SFMC Auth URL) they place their SFMC instances authentication URL as username e.g.: https://THEIR_SUBDOMAIN.auth.marketingcloudapis.com/v2/token. And enter any value as password so they can save the entry

 

Example: SFMC API Credentials

Example: SFMC Auth URL

 

Note: the Extension API and Contacts API integration can use the same credentials

Step 2

Fieldmapping

Setup the Fieldmapping based on the Worksheet provided by the client. And adjust the demo form in their console to match all the fields they want to collect.

 

Example: Salesforce - MC - Extension API FieldMapping

 

As this is a POST XML/JSON integtration also the JSON part will need to be adjusted for every field added.

Note: The email address is not mapped directly in the JSON but is a dynamic variable at the end of the URL in the Integration Settings. However it is added to the Fieldmapping to prevent completely empty submissions.

 

Example: Salesforce - MC - Extension API FieldMapping Settings

 

Recommendation: In order to keep Fieldmappings as flexible as possible only make the e-mail address required. This tends to allow the fieldmapping to be reused with a lot of variations of form in creative.

 

In order to dispel the concerns of the client. Fields can still be made required in the form in the creative to make sure all data they want is collected.

Step 3

Integration

Setup the Integration using the Fieldmapping created in the previous step.

  • When placing the URL make sure to replace the placeholders for THEIR_SUBDOMAIN AND THEIR_EXTENSION_KEY with the actual values.

 

https://THEIR_SUBDOMAIN.rest.marketingcloudapis.com/hub/v1/dataevents/key:THEIR_EXTENSION_KEY/rows/EmailAddress:{{EmailAddress}}

 

The email address will be appended via dynamic content insertion as long as they are collecting/storing it with a datafield that saves it under the Key EmailAddress (case-insensitive)

 

  • Ensure the Method for this call is set to PUT
  • Add the additional HTTP Header
    • Using Authorization as name
    • Using Bearer {{access_token}} as value

 

Example: Salesforce - MC - Extension API

Step 4

Server Scriptlet

Create a new Server scriptlet in their console.

You should be able to directly copy the code from the Server Scriptlet Example.

Depending on the names chosen for the credentials and the integrations itself the lines 2,3 and 4 might need to be updated to match the chosen names.

 

Example: Salesforce Marketcloud - Auth/RunIntegration

 

When triggered the scriptlet is running a request to the URL provided in the Credential Set SFMC Auth URL using the clientID and clientSecret from SFMC API Credentials.

And then triggers the integration named on line 4 e.g.: Salesforce - MC - Extension API

Step 4

Creative

Add the trigger for the Server Scriptlet. This is usually the submit button on the form. But can be placed anywhere that allows you to add Rules to an action or a Page.

 

Example: Salesforce Marketcloud - XML/JSON (Extension API) - Add Lead

 

Note: The Mark to re-run rule is integrated in the server scriptlet on line 55 (actionMarkReexport)

Footer Headline Goes Here

Address, State, Country

1-800-000-0000

help@emailhere.com