Overview
Integrate the Salesforce Interactions SDK
Integrate Salesforce Personalization with Modern Frontend Frameworks
Request Personalization Through the Sitemap
Example Sitemap
Track Personalization Engagement
Here’s an example of a Salesforce Interactions SDK sitemap that tracks user engagement when a visitor lands on the homepage and identifies content zones where personalized content can be injected.
This example Sitemap is for reference only. Avoid using this Sitemap code or the provided frontend logic in your own implementation as it may not produce the same results.
Important
1/* ========= START: PERSONALIZATION INITIALIZATION ========= */
2SalesforceInteractions.Personalization.Config.initialize({
3 customFlickerDefenseConfig: {
4 redisplayTimeoutMilliseconds: 2000,
5 renderPersonalizationAfterTimeoutElapsed: false,
6 },
7});
8/* ========= END: PERSONALIZATION INITIALIZATION ========= */
9SalesforceInteractions.init({
10 personalization: {
11 dataspace: "default",
12 },
13 consents: [
14 {
15 purpose: SalesforceInteractions.ConsentPurpose.Tracking,
16 provider: "Example Consent Manager",
17 status: SalesforceInteractions.ConsentStatus.OptIn,
18 },
19 ],
20}).then(() => {
21 const sitemapConfig = {
22 pageTypeDefault: {
23 name: "default",
24 interaction: {
25 name: "default",
26 eventType: "userEngagement",
27 },
28 },
29 pageTypes: [
30 {
31 name: "home",
32
33 isMatch: () => window.location.pathname === "/",
34
35 interaction: {
36 name: "home view",
37 eventType: "userEngagement",
38 },
39 contentZones: [
40 { name: "recommendations_1", selector: "section.product_recs" },
41 { name: "recommendations_2", selector: "div#customer-stories" },
42 ],
43 },
44 ],
45 };
46 SalesforceInteractions.initSitemap(sitemapConfig);
47 /* === SPA Websites === */
48 let currentUrl = window.location.href;
49 setInterval((_) => {
50 if (currentUrl !== window.location.href) {
51 currentUrl = window.location.href;
52 SalesforceInteractions.reinit();
53 }
54 }, 500);
55});