Marketing Cloud Personalisation Sitemap Coding Tips

  • Related Catalog Objects should always be returned in an array [], and as strings
RelatedCatalogObject: () => SalesforceInteractions.util.resolveWhenTrue.bind(() => {
     if (conditionA) {
          return [valueA];
     } else if (conditionB) {
          return [valueB];
     } else {
          return [];
     }
})
  • If a dataLayer parameter is available in console.log, but the sitemap is not passing the data to MCP, it’s likely a timing issue. Wait until the parameter exists with this function:
name: () => {
       return SalesforceInteractions.util.resolveWhenTrue.bind(() => {
           if (dataLayer.blogTitle) { return dataLayer.blogTitle };
       }); 
}
  • If you encounter issues with content zones not appearing in the Web Template content zone selector, there is a workaround: manually set the content zone in the Web Template
  • Don’t add a selector next to the global_popup content zone. This can cause a webpage to flicker contentZones: [ {name: "global_popup"} ]
  • If a website form appears in a pop up, or on multiple pages, add the form submit interaction event to the global listeners section
  • In Product Catalog View Item events, make sure the object is nested correctly, with attributes & relatedCatalogObjects inside the catalogObject
SalesforceInteractions.sendEvent({
     interaction: {
           name: SalesforceInteractions.CatalogObjectInteractionName.ViewCatalogObject,
           catalogObject: {
                type: "",
                id: "",
                attributes: {},
                relatedCatalogObjects: {}
           }
      },
      source: {
          pageType: "", 
      }
});
  • If a CORS policy is set to “Report Only”, this means the CORS policy is not enforced. CORS errors will be bypassed and the Visual Editor should open provided x-frame-options is set to sameorigin.
  • CORS errors do not necessarily mean the website’s content security policy is responsible for the error occurring.

    “Blocked by CORS policy: The value of ‘Access-Control-Allow-Credentials’ header in the response is ‘ ‘ which must be ‘true’ when the credentials mode is ‘include’.”
    • Check the sitemap coding! In this example, the CORS error was resolved by updating the user id attribute in a form submission event, which was coded for SalesforceInteractions when it should have been coded for the Evergage namespace because it was an old sitemap.
// SalesforceInteractions
user: {
   id: {
      emailAddress: email
   }
}
// Evergage
user: {
    id: email
}
  • “Response was not Ok: Event was missing core field: userId (ID of current user or email address)”
    • This error can appear for any error in the sitemap; it may not be related to the user id at all. Check the cookieDomain has been set correctly for the URL you are working on