CDP4S uses Sitecore CDP Full Stack Experiences to send and retrieve Guest data.
Audience Template
Create a new Real-Time Audience Template under Library > Audience Templates. This allows restricting data sent to Salesforce to avoid unnecessarily exceeding API limits. Create a JavaScript function as follows to limit to identified (Customer type) Guests only:
// Include only identified (Customer type) Guests. (function () { return (guest.guestType == 'customer'); })();
Add further restrictions if you have specific requirements.
Triggered Experience
Create a Full Stack Triggered Experience to automatically send Guest data to Salesforce. For the trigger we recommend:
Session Closed to send when a Guest session ends, or
Custom Trigger on the IDENTITY event to send as soon as the Guest is identified, or
both of the above
Limit the Audience using the Audience Template created above.
Create a Webhook variant that sends to the Destination Connection created above. Create the API response with the following Freemarker template:
<#-- Output all Guest data. --> ${toJSON(guest)}
Interactive Experience
Create a Full Stack Interactive Experience with the same Audience Template and API response as above. Note the friendlyId value for configuration in Salesforce - this Experience will be used to retrieve Guest data on demand.