Configuring a container invocation script
To facilitate the invocation of Real-Time Container APIs, Pega Customer Decision Hub includes an out-of-the-box sample JavaScript file - webwb/RealTimeContainerScript.js
Pega Customer Decision Hub
This script includes a service controller object which has methods that invoke the various Container APIs.
To utilize this script, perform the following steps:
- Download and copy the JavaScript file to your web directory.
- Include the file in your web content. For
example:
<script src="https://docs-previous.pega.com/realtimecontainerscript.js" />
- Instantiate the service controller object. For
example:
var nbamServiceCtrl = getNBAMServiceControl();
-
Initialize the service controller object using one of the following mechanisms.
- Directly update serverHostName and serverPort in realtimecontainerscript.js, as shown
in the snippet below. When using this mechanism, the instantiation of the service
controller (Step 3 above) will already initialize the controller using these
values.
var serverHostName = "localhost";var serverPort = "8080";
- Invoke the initialize method on the service controller after instantiating it. For
example:
nbamServiceCtrl.initialize(window.location.hostname, window.location.port);
- Directly update serverHostName and serverPort in realtimecontainerscript.js, as shown
in the snippet below. When using this mechanism, the instantiation of the service
controller (Step 3 above) will already initialize the controller using these
values.
Invoke the desired API using the corresponding service controller method.
Service API JavaScript Method Method Parameters Container getOffers customerID, containerName, channel, previousPage, currentPage, callback V2 Container loadOffers jsonObj, methodType, callback CaptureWebImpression captureSingleWebImpression containerID, customerID, offerID, issue, group, interactionID, callback CaptureWebResponse captureWebResponse containerID, customerID, offerID, issue, group, interactionID, outcome, behavior, channel, direction, callback CaptureResponse captureResponse containerID, customerID, offerID, issue, group, interactionID, outcome, behavior, channel, direction, callback CapturePaidResponse capturePaidClickResponse CustomerID, ExternalAudienceId, ReferrerUrl, Utm_medium, callback
Previous topic Capturing clicks on the click-through URL Next topic Invoking a fallback strategy