The global Sitemap configuration object in the SalesforceInteractions namespace allows you to define common behaviors and data capture across all pages of a website, rather than specifying these configurations individually for each page type. This approach ensures consistency and reduces redundancy in your code.
Global Configuration:
Purpose: The global configuration section defines settings and behaviors that apply universally to all matched page types on the website.
Elements: Common elements configured globally include content zones, event listeners, locales, and onActionEvent functions.
Content Zones:
Definition: Content zones are specific areas on the page where dynamic content can be displayed or personalized. They are identified by their CSS selectors.
Example: In the provided example, three content zones are defined:
global_infobar_top_of_page: Targets the header section of the site (header.site-header).
global_infobar_bottom_of_page: Targets the footer section (footer.site-footer).
global_popup: A general content zone without a specific selector, likely meant for popups.
Listeners:
Definition: Listeners are functions that watch for specific events (e.g., form submissions, clicks) on the page. When the event occurs, the listener triggers an action, such as sending an event to Salesforce Personalization.
Example: A listener is set up for the "submit" event on a form with the class .email-signup. When the form is submitted, the listener captures the email entered by the user and sends an event labeled "Email Sign Up - Footer" along with the user's email address.
Locale:
Definition: Although not shown in this example, the locale property can be used to define the language or region-specific settings globally. This would apply to all pages that match the sitemap configuration.
onActionEvent Functions:
Definition: onActionEvent functions globally modify the behavior or data of user actions before sending them to Salesforce Personalization. These functions are defined globally and apply to all matching page types unless overridden on a specific page type.
SalesforceInteractions.init({
cookieDomain: "northerntrailoutfitters.com"
}).then(() => {
const sitemapConfig = {
global: {
contentZones: [
{name: "global_infobar_top_of_page", selector: "header.site-header"},
{name: "global_infobar_bottom_of_page", selector: "footer.site-footer"},
{name: "global_popup" }
],
listeners: [
SalesforceInteractions.listener("submit", ".email-signup", () => {
const email = SalesforceInteractions.cashDom("#dwfrm_mcsubscribe_email").val();
if (email) {
SalesforceInteractions.sendEvent({
interaction: { name: "Email Sign Up - Footer" },
user: { identities: { emailAddress: email } }
});
}
}),
],
},
pageTypes: [ /* ...page type configurations... */ ]
}
SalesforceInteractions.initSitemap(sitemapConfig);
});