Custom Events

Use the recommended Cart Interaction, Catalog Interaction, and Order Interaction data models provided by the Salesforce Interactions SDK to use the unified data model across Salesforce. You can create and capture custom events in addition to the recommended interaction data models.
Define the shape of the custom event in the Web Connector schema. For example:
1{
2  "records": [
3    {
4      "developerName": "myCustomEvent",
5      "masterLabel": "My Custom Event",
6      "category": "Engagement",
7      "externalDataTranFields": [
8        {
9          "masterLabel": "My Custom Field",
10          "dataType": "Text",
11          "developerName": "myCustomField",
12          "isDataRequired": true
13        },
14        {
15          "masterLabel": "My Custom Num Attribute",
16          "dataType": "Number",
17          "developerName": "attributesMyCustomNum",
18          "isDataRequired": true
19        },
20        {
21          "masterLabel": "My Custom Text Attribute",
22          "dataType": "Text",
23          "developerName": "attributesMyCustomText",
24          "isDataRequired": true
25        },
26        {
27          "masterLabel": "eventId",
28          "dataType": "Text",
29          "developerName": "eventId",
30          "isDataRequired": true,
31          "primaryIndexOrder": 1
32        },
33        {
34          "masterLabel": "category",
35          "dataType": "Text",
36          "developerName": "category",
37          "isDataRequired": true
38        },
39        {
40          "masterLabel": "dateTime",
41          "dataType": "DateTime",
42          "developerName": "dateTime",
43          "isDataRequired": true
44        },
45        {
46          "masterLabel": "deviceId",
47          "dataType": "Text",
48          "developerName": "deviceId",
49          "isDataRequired": true
50        },
51        {
52          "masterLabel": "eventType",
53          "dataType": "Text",
54          "developerName": "eventType",
55          "isDataRequired": true
56        },
57        {
58          "masterLabel": "sessionId",
59          "dataType": "Text",
60          "developerName": "sessionId",
61          "isDataRequired": true
62        }
63      ]
64    }
65  ]
66}

Then, in Salesforce Interactions SDK, specify the eventType or name field, and required fields that aren’t set via Automatic Population of Required Fields to capture this event.

1SalesforceInteractions.sendEvent({
2  interaction: {
3    name: 'myCustomEvent',
4    eventType: 'myCustomEvent',
5    myCustomField: 'some value'
6    attributes: {
7        myCustomNum: 1234,
8        myCustomText: "abcd"
9  }
10})

This drives the SDK to emit an event such as this to Data Cloud:

1{
2"events": [{
3    "eventType": "myCustomEvent",
4    "myCustomField": "some value",
5    "attributesMyCustomNum": 1234,
6    "attributesMyCustomText": "abcd",
7    "eventId": "100d237b-e464-44df-9556-7481bbf52685",
8    "dateTime": "2022-10-18T18:25:26.680Z",
9    "sessionId": "6b6c33bfcfee93f4",
10    "deviceId": "6b6c33bfcfee93f4",
11    "interactionName": "myCustomEvent",
12    "sourceUrl": "https://{my site}",
13    "sourceUrlReferrer": "https://{my site}",
14    "sourceChannel": "Web",
15    "sourcePageType": "test",
16    "category": "Engagement"
17}]
18}

If eventType isn’t provided but name is, then eventType defaults to the value of name.

Note