Custom Events
The Salesforce Interactions SDK and the Personalization module feature several built-in CustomEvents that you can use to bind listeners specific to the Web SDK. You can find the data passed by these CustomEvents in the detail
property of the event object passed to a listener's callback function.
The Salesforce Interactions SDK and Personalization module provide the following built-in custom CustomEvents in each of the namespaces.
The following code sample depicts how you can use an mcis:onStatSend
or evergage:onStatSend
CustomEvent to dispatch a CustomEvent whenever a campaign stat is logged and sent via Evergage.sendStat
.
The mcis:onEventResponse
or evergage:onEventResponse
CustomEvent is dispatched whenever an Event API request returns a response. This CustomEvent contains the actionEvent
payload sent to the Event API and any returned campaign data, such as the names and IDs of campaigns and experiences.
The OnEventResponse
CustomEvent contains the following detail
.
The ActionEventResponse
object has the following structure.
The ActionEvent
object has the following structure.
The mcis:onBeforeEventSend
or evergage:onEventSend
CustomEvent is dispatched before an event is sent to Personalization. This CustomEvent has the following structure and contains the actionEvent
payload to be processed in the event pipeline. Both CustomEvents can be canceled to prevent the event from being sent to Personalization.
The ActionEvent
object has the following structure.
The following code example depicts canceling the OnEventSend
CustomEvent to prevent the event from being sent to Personalization.
The interactions:onException
or evergage:onException
CustomEvent is dispatched when an operation fails and contains information about the error and its context. You can use the OnException
CustomEvent for debugging and logging runtime errors.
The OnException
CustomEvent contains the following detail
.
The Error
object has the following structure.
The mcis:onInit
or evergage:onInit
CustomEvent is dispatched when the Personalization module of the Salesforce Interactions SDK is initialized. You can use the OnInit
CustomEvent for debugging single-page applications (SPA) where the beacon and the sitemap usually have to reinitialize without a page load event.
The OnInit
CustomEvent contains the following detail
.
The BeaconConfig
object contains internal configuration in order for the Web SDK to run properly. Do not reference these fields as they are subject to change.
The interactions:onShutDown
or evergage:onShutDown
CustomEvent is dispatched whenever the Salesforce Interactions Web SDK is shut down and contains the shutdown message with the following detail
.
The interactions:onInitSitemap
or evergage:onInitSitemap
CustomEvent is dispatched whenever a sitemap is initialized via the SalesforceInteractions.initSitemap
or Evergage.initSitemap
function and contains the following detail
.
The SiteMapConfig
object has the following structure.
The interactions:onPageMatchStatusUpdated
or evergage:onPageMatchStatusUpdated
CustomEvent is dispatched whenever the match status of a sitemap's page type is updated. The matchStatus
array accumulates every time an OnPageMatchStatusUpdated
CustomEvent is dispatched, in the order the match statuses are updated. If the status is running
, the PageMatchStatus
includes the start time. Conversely, if the status is selected
, rejected
, or matched
, the PageMatchStatus
includes the end time. The selected
page type is the first page type to be matched. The sitemap does not evaluate other matched
page types.
The OnPageMatchStatusUpdated
CustomEvent contains the following detail
.
The PageMatchStatus
object has the following structure.
The mcis:onStatSend
or evergage:onStatSend
CustomEvent is dispatched when a stat is tracked and can be used to send Personalization campaign stats to third-party tracking tools, such as Google Analytics and Adobe Analytics.
The OnStatSend
CustomEvent is dispatched with or without the Campaign Stats Gear. For more information on sending campaign stats with or without the Campaign Stats Gear, refer to the Campaign Stats Tracking documentation.
The OnStatSend
CustomEvent contains the following detail
.
The CampaignStat
object has the following structure.
The CampaignResponse
object has the following structure.
When enabled, the Handlebars Gear dispatches the mcis:onTemplateDisplayEnd
or evergage:onTemplateDisplayEnd
CustomEvent on rendering templates. The Campaign Stats Gear listens for this CustomEvent to track campaign stats. Server-side campaigns require the OnTemplateDisplayEnd
CustomEvent to be manually dispatched. For instructions on how to dispatch an OnTemplateDisplayEnd
CustomEvent manually without the Handlebars Gear, refer to the Web Campaign Stats documentation.
The OnTemplateDisplayEnd
CustomEvent contains the following detail
.
The interactions:onConsentRevoke
or evergage:onConsentRevoke
CustomEvent is dispatched when a Consents status is changed from Opt In
to Opt Out
. This CustomEvent contains information about the Consent that was revoked with the following detail.
The Consent
object included in the OnConsentRevoke
CustomEvent detail is the consent that was updated and has the following structure.
The following CustomEvents are only dispatched on the SalesforceInteractions
namespace.
The interactions:onBeforeEventSend
CustomEvent is dispatched by the Salesforce Interactions Web SDK before an event is sent to any modules. This CustomEvent contains the event from the Salesforce Interactions Web SDK and the following detail.
The ActionEvent<Interaction>
object has the following structure.
The interactions:onSetAnonymousId
CustomEvent is dispatched when an anonymousId is set and contains the following detail.
The interactions:onResetAnonymousId
CustomEvent is dispatched when the anonymousId is reset through a call to SalesforceInteractions.resetAnonymousId
.
The interactions:onClearCookie
CustomEvent is not dispatched by the Salesforce Interactions Web SDK but can be manually dispatched to clear any cookies set by the Web SDK. This CustomEvent can be used to instruct the Salesforce Interactions Web SDK to remove any cookies it has set. The interactions:onClearCookie
CustomEvent optionally allows for the following detail where domain
is the cookieDomain
used for setting cookies in the Web SDK.
The following code sample depicts dispatching this CustomEvent with a specified domain.