CMS Connector Page Code

If you use CMS Connect to render personalized content in your Experience Builder site, your setup process requires the following connector JSP page code.

To get your personalized content from Adobe Experience Manager working in your site, create a JSP connector page that contains the following code. You can add to this code as needed.

The connector JSP page logic includes these sections.

  • Request parameter. The request parameter (payload) contains the data that a site passes to the connector page. It contains:
    • componentUrls—an array of component path URLs for which personalization must be run
    • asset—a JavaScript asset specified in the Asset Path field in the CMS connection that is injected when the JSP page loads
    • clientContext—IP address, language, country, state, city, latitude, and longitude
    • requestId—a token returned as part of the postMessage to validate the authenticity of the response
    • domain—the domain of the site requesting personalized content
  • Personalization JSP logic. We provide you with the basic logic. You can add logic as needed.
  • JavaScript. In your JSP, include Salesforce-provided JavaScript that sends a postMessage to your site. Construct the script src like this: \<your_site_domain/_sfdc/cms-connect/aem_personalization/salesforceConnector.js>. Any asset specified in the Asset Path field in the CMS connection is included in your JSP.
  • Response. The final section constructs the response object. The JavaScript that you include in the previous section does the postMessage.

To ensure that the connector page code gets personalization working in your site, follow these guidelines.

  • Don’t change any request parameter values.
  • Don’t take out any try/catch blocks. These blocks handle the case where something goes wrong in the connector page code.
  • Don’t change the structure of the response object in the postMessage.