How to Use Salesforce Custom Interactions to Instrument Custom Analytics Events Into ISVapp
Table of contents
What can I do with Custom Interactions?
Custom Interactions is the name of a new, native Salesforce Apex feature that allows ISV and OEM partners to send custom events to the AppAnalytics data stream. The feature will be available to use in Apex starting with the Spring '24 release in February 2024.
ISVapp leverages the AppAnalytics data stream to allow detailed, over-time, usage analytics, health scores, retention analysis and alerts.
What are common use cases for Custom Interactions?
Salesforce AppAnalytics does already track a list of component interactions automatically. Most things that are part of your managed package ― custom objects, Visualforce pages, Lightning components, certain Apex function calls ― are mostly covered by AppAnalytics. We have documented the available events in this guide. You can already use and analyze all of these events in ISVapp using our Feature Management module.
There are however key events in your product or during the customer lifetime that you cannot track using the available data in AppAnalytics. The release of Custom Interactions changes that and is a great addition to the AppAnalytics API. Here are few use cases:
Tracking key events (success, finish, failure) within a certain business process
Tracking record creations of Standard Objects via managed triggers (Accounts, Opportunities etc.)
Tracking certain adoption milestones, e.g. "Customer has performed Action A, B and C"
Understanding specific user flows
Tracking Lightning and Visualforce user interface interactions
How does it look?
The following is a simplified example of a standard Apex code snippet that can be used to track a custom interaction (Source: Salesforce Webinar Hacking Growth with App Analytics):
private enum CustomInteractionLabel {
Product_ProductArea_OperationA,
Product_ProductArea_OperationB,
// You can define any number of enums that describe events that you'd like to track
}
// Track the interaction anywhere in your managed package's Apex code
ISVPartners.AppAnalytics.logCustomInteraction(CustomInteractionLabel.Product_ProductArea_OperationA)
Naming best practices
Decide on a naming pattern once and stick with it
Choose a single place in your codebase where all custom interaction labels are defined and where your naming convention is being documented
Prefix your events with the product, product area or component where it is triggered in. Introducing a hierarchy early on helps to keep things organized.
If you maintain a ISVapp product taxonomy, applying the same hierarchy naming pattern in your custom interaction labels will make the mapping of events to ISVapp features straightforward
The enum class you choose will be included in the event name. Events from our example above will show up as CustomInteractionLabel.Product_ProductArea_OperationA in the logs.
Developers might persist on specifying enums in ALL_CAPS since it is the standard for enums in code. However, using camel case can greatly improve the readability for long custom interaction labels. See the following examples:
InteractionLabels.FeatureManagement_FeatureEditor_CreateFeatureButton
InteractionLabels.FEATUREMANAGEMENT_FEATUREEDITOR_CREATEFEATUREBUTTON
InteractionLabels.FEATURE_MANAGEMENT_FEATURE_EDITOR_CREATE_FEATURE_BUTTON
Timeline
Custom Interactions are fully available within the ISVapp Feature Management.
Sources
Custom Interactions Salesforce Release Notes
Implementation Guide on the Salesforce Documentation
Salesforce Webinar Hacking Growth with App Analytics by Ben Easly and John Belo