Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

Configuring a container invocation script

Updated on September 15, 2022

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:

  1. Download and copy the JavaScript file to your web directory.
  2. Include the file in your web content. For example:
    <script src="" />
  3. Instantiate the service controller object. For example:
    var nbamServiceCtrl = getNBAMServiceControl();

    To invoke a Container with the V3 service, instantiate:

    var nbamServiceCtrl = getNBAMServiceControl()("V3");

    To invoke multiple Containers with the V3 service, instantiate:

    var nbamServiceCtrl = getNBAMServiceControl()("V3", true);
  4. Initialize the service controller object using one of the following mechanisms.
    1. 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";
    2. Invoke the initialize method on the service controller after instantiating it. For example:
      nbamServiceCtrl.initialize(window.location.hostname, window.location.port);
  5. Invoke the desired API using the corresponding service controller method.

    Service APIJavaScript MethodMethod Parameters
    ContainergetOfferscustomerID, containerName, channel, previousPage, currentPage, callback
    V3 ContainerloadOffersjsonObj, methodType, callback
    CaptureWebImpressioncaptureSingleWebImpressioncontainerID, customerID, offerID, issue, group, interactionID, callback
    CaptureWebResponsecaptureWebResponsecontainerID, customerID, offerID, issue, group, interactionID, outcome, behavior, channel, direction, callback
    CaptureResponsecaptureResponsecontainerID, customerID, offerID, issue, group, interactionID, outcome, behavior, channel, direction, callback
    CapturePaidResponsecapturePaidClickResponseCustomerID, ExternalAudienceId, ReferrerUrl, Utm_medium, callback

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us