Coachmark is a category of JavaScript packages (also known as libraries or modules) designed to help developers create interactive, guided tours, and onboarding experiences within web applications. The primary goal of Coachmark libraries is to highlight and explain specific UI elements, features, or workflows to users, enhancing their understanding and adoption of the application.
Key features of Coachmark JavaScript packages (note: there might be multiple packages with similar names, but I'll outline common features found in such libraries):
Tooltips and Popovers: Display contextual information next to or over specific UI elements.
Step-by-Step Guides: Create sequenced tours that guide users through complex workflows or feature sets.
Highlighting: Visually emphasize targeted UI elements to draw the user's attention.
Customizable: Often allows for customization of appearance, behavior, and content to fit the application's branding and needs.
Triggering Options: May include various trigger methods (e.g., click, hover, automatically on page load, based on user behavior).
Examples of Coachmark JavaScript packages:
Shepherd (popular, widely used)
Driver.js
Intro.js
Hopscotch
Can I use a Coachmark JavaScript package with Salesforce?
Yes, you can use a Coachmark JavaScript package with Salesforce, but with some considerations and potential limitations depending on how and where you intend to deploy it within the Salesforce ecosystem. Here’s a breakdown by Salesforce interface/context:
Salesforce Lightning Web Components (LWC) or Aura Components:
Feasible: You can incorporate a Coachmark library within custom-built LWCs or Aura components. This requires loading the library (e.g., via a CDN or by uploading it as a static resource) and then integrating it into your component.
Considerations: Ensure the library is compatible with Salesforce’s Content Security Policy (CSP) and that you handle any potential conflicts with Salesforce’s own UI libraries. When using Locker Service in Lightning, you may need to wrap the library to ensure compliance.
Example (using Shepherd in an LWC):
javascript
// Import Shepherd in your LWC
import { LightningElement } from 'lwc';
import shepherdJs from '@salesforce/resourceUrl/shepherd';
import { loadScript } from 'lightning/platformResourceLoaders';
export default class MyComponent extends LightningElement {
connectedCallback() {
// Load Shepherd library dynamically
loadScript(this, shepherdJs).then(() => {
const tour = new Shepherd.Tour({
defaults: {
classes: 'shadow-md bg-white',
},
});
tour.addStep({
title: 'Welcome to My App',
text: 'This is a guided tour.',
attachTo: {
element: this.template.querySelector('.my-element'),
on: 'bottom',
},
});
tour.start();
});
}
}
Visualforce Pages:
Feasible: Similar to LWCs/Aura, you can include a Coachmark library in Visualforce pages by loading the JavaScript and CSS resources directly into your page or via a static resource.
Considerations: Be mindful of Visualforce page limitations, especially if the page is intended for use in Salesforce Mobile Apps or if it needs to adhere to very specific security requirements.
Example (including Shepherd in a Visualforce page):
html
<apex:page>
<apex:includeScript value="{!$Resource.Shepherd}" />
<div id="my-element">Target Element</div>
<script>
const tour = new Shepherd.Tour({
defaults: {
classes: 'shadow-md bg-white',
},
});
tour.addStep({
title: 'Welcome to My App',
text: 'This is a guided tour.',
attachTo: {
element: document.querySelector('#my-element'),
on: 'bottom',
},
});
tour.start();
</script>
</apex:page>
Salesforce Communities or Experience Cloud:
Generally Feasible: The approach would be similar to integrating with LWCs or Visualforce, but ensure the library works well with the Community’s theme and layout.
Considerations: Theme and branding customizations might require additional work to ensure seamless integration.
Not Recommended/Feasible: You cannot directly add custom JavaScript libraries to modify the native Salesforce UI without using one of the custom development paths (LWC, Aura, Visualforce, etc.).
Before Proceeding:
Check Compatibility: Ensure the Coachmark library you choose is compatible with your Salesforce environment (e.g., works with Locker Service in Lightning).
Security Review: Perform a security review, especially if handling sensitive data, to ensure compliance with Salesforce’s security guidelines.
Test Thoroughly: Conduct thorough testing across different browsers and devices to ensure the library integrates smoothly without disrupting the user experience.
Addressing Potential Challenges:
Locker Service Compliance: When using Coachmark libraries in Lightning, ensure they are wrapped or modified to comply with Locker Service restrictions. This may involve creating a wrapper library or using a build process to ensure compatibility.
Content Security Policy (CSP): To ensure CSP compliance, use Salesforce’s approved methods for loading external scripts, such as loadScript from lightning/platformResourceLoaders. Avoid using inline scripts or unsafe-eval whenever possible.