1. Introduction
Currently, Piano Content can only be enabled on production environments. If you need to test how Piano Content widgets render on a Sandbox site before going live, you can display widgets by triggering them with a RunJS action.
2. Prerequisites
Before running the widget, make sure the required scripts are available on the staging/sandbox page:
-
cx.cce.jsmust be implemented on the publisher's staging site for this to work. -
In some implementations, you may also need
cx.jspresent on the page.
Example script includes:
<script type="text/javascript" src="https://cdn.cxense.com/cx.cce.js"></script>
<script type="text/javascript" src="https://cdn.cxense.com/cx.js"></script>
If your site already loads these libraries through a tag manager or your base template, you do not need to add them again.
3. RunJS Code to Display a Widget
Use a RunJS card (in Composer) and execute the following JavaScript:
var cX = window.cX = window.cX || {};
cX.callQueue = cX.callQueue || [];
cX.CCE = cX.CCE || {};
cX.CCE.callQueue = cX.CCE.callQueue || [];
cX.CCE.run({ widgetId: <widgetId>, targetElementId: <target element ID> });
Replace the following values:
-
<widgetId>— the Piano Content widget ID you want to render. -
<target element ID>— the ID of the DOM element where the widget should be injected.
4. Notes and Troubleshooting
-
This is a display-only workaround for sandbox testing. Since Piano Content activation and enhanced segmentation are production-only, sandbox testing is primarily useful to validate implementation, placement, and layout/UX.
-
Nothing appears on the page: Confirm
cx.cce.jsis loading successfully on the staging page and that thetargetElementIdexists in the DOM at the time the RunJS executes. -
Target element issues: Ensure the target element uses an
idattribute that exactly matches what you pass astargetElementId(IDs are case-sensitive).