In Salesforce Personalization (formerly known as Evergage), a Sitemap is a critical configuration that defines how different pages on your website are identified and what data is collected or actions are taken on those pages. The initialization of the Sitemap is the final step in setting up this configuration.
Sitemap Initialization:
The Sitemap is initialized at the end of your JavaScript configuration by calling either:
SalesforceInteractions.initSitemap(sitemapConfig) in the SalesforceInteractions namespace.
Evergage.initSitemap(sitemapConfig) in the Evergage namespace.
This initialization process is essential because it starts the tracking of Sitemap events. Without this step, no data will be collected, and no events will be tracked for the defined page types.
sitemapConfig:
The sitemapConfig object is passed as an argument during initialization. This object includes:
global: The global configuration object, which applies to all pages.
pageTypes: An array of page type configurations that define how specific pages are identified and what actions should be taken on those pages.
Tracking and Page Matching:
Sitemap events (e.g., page views, interactions) are only tracked if:
The Sitemap has been successfully initialized.
The current page matches one of the defined page types in the pageTypes array.
If there are errors in the Sitemap configuration or if no page types match the current page, tracking will not occur, and errors may be encountered.
SalesforceInteractions.init({
cookieDomain: "developer.evergage.com"
}).then(() => {
const sitemapConfig = {
global: {...global object configuration...},
pageTypes: [...page type array configuration...]
}
SalesforceInteractions.initSitemap(sitemapConfig);
});
SalesforceInteractions.init({...}): This function initializes the SalesforceInteractions environment. It typically includes parameters such as cookieDomain, which defines the domain where cookies should be set.
then(() => {...}): Once the initialization of SalesforceInteractions is complete, the function within the then block is executed. This is where the Sitemap configuration and initialization occur.
sitemapConfig: This object contains the global settings and the array of page type configurations, as discussed in the previous sections.
SalesforceInteractions.initSitemap(sitemapConfig): This function call actually initializes the Sitemap using the provided configuration. From this point on, the defined page types will be matched, and the corresponding events will be tracked.