Custom Personalization Extension
Send2CRM provides the ability to make custom modifications to personalization data in visitor responses to the web client.
Autolaunched Flow
A Flow can be run to modify personalization data during a visitor update request. This is run immediately after populating personalization data as defined by field mappings, and passed the following variables:
The applicable s2cVisitor__c record (input only).
The prepared personalization data (input and output).
Create Flow and configure variables
Create an Autolaunched Flow (No Trigger).
Add two Resources:
 | Visitor record | Personalization data |
---|---|---|
Resource Type | Variable | Variable |
API Name | VisitorRecord | VisitorData |
Data Type | Record | Apex-Defined |
Object | Send2CRM Visitor | Â |
Apex Class | Â | send2crm__GenericFlowData |
Allow multiple values (Collection) | Â | Checked |
Available for input | Checked | Checked |
Available for output | Â | Checked |
The API Names must be exactly as shown above, or the data will not be passed to the Flow.
Generic Flow Data object
The send2crm__GenericFlowData class provides an object that can be used to construct key-value pairs for personalization. It has the following properties:
accessor: the property accessor used to set the key. This may include multiple colon-separated values to implement nested arrays and objects, in the same manner as form submissions and event data.
valueAsString
valueAsNumber
valueAsDatetime
valueAsBoolean
You should only set one of the valueAs<Type> properties at a time, to ensure that the correct value is applied. It may be easiest to define multiple single variables if assigning many different values.
Build Flow logic
Build out the logic to generate the personalization data.
Related records can be loaded using the lookup Ids on the visitor record.
Use a single send2crm__GenericFlowData variable to apply personalization values. Assign the accessor and value to the single variable, then add the single variable to the VisitorData collection.
Activate the Flow.
See the Subscriptions example for more details.
Access permissions
If using a public Site for the Send2CRM API, permission to access the Flow will need to be configured.
https://help.salesforce.com/s/articleView?id=sf.rss_flow_guestuser.htm&type=5
On the Flows index page in Setup, click the actions dropdown beside the Flow, and Edit Access.
Check Override default behavior and restrict access to enabled profiles or permission sets, and save.
View the Site configuration in Setup, and click the Public Access Settings button at top.
Locate the Enabled Flow Access section and click Edit.
Add the desired Flow from Available Flows to Enabled Flows, and save.
Send2CRM configuration
Configure Send2CRM to use the Flow for personalization by editing the org-wide Custom Settings and specifying the API name of the Flow under Personalization Flow. If your Flow has a namespace, this should be of the form namespace.flowApiName
.
Apex implementation
For even more control, Send2CRM allows custom personalization via Apex. Simply implement the PersonalizationPlugin
interface:
global interface PersonalizationPlugin {
/**
* @description Process personalization data.
* @param visitorObj The Visitor record.
* @param data Visitor data that will be returned to client. Modify this map to customize.
*/
void process(s2cVisitor__c visitorObj, Map<String, Object> data);
}
If using a public Site for the Send2CRM API, implementing classes should use global inherited sharing
, because form validation occurs during anonymous calls to public endpoints. The context user is that configured in the Salesforce Site.
Configure your code to make the desired modifications to the data
Map. Any objects supported by JSON.serialize()
can be returned to the web client!
Troubleshooting
Exceptions caused by personalization plugins are caught and will not cause a visitor update request to fail. If this occurs then personalization modifications will not be applied.
The provided Flow plugin outputs debug logging that can be used to locate problems.
Performance considerations and API limits
Personalization plugins allow modifying data during the Send2CRM visitor update request, care should be taken to avoid negative performance impact:
If using public Sites, any custom implementation will count toward the Site limits.
Slow processes will delay the response to the website client.
Salesforce Apex and SOQL query transaction limits need to be considered, especially if using the Scaling service to combine multiple requests.
For complex processes, consider building and storing a redundant copy of the data prior to delivering it in the visitor response.