Skip to main content
LinkedIn
Copied!

Table of Contents

Configuring a container invocation script

Version:

Only available versions of this content are shown in the dropdown

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

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="https://community.pega.com/realtimecontainerscript.js" />
  3. Instantiate the service controller object. For example:
    var nbamServiceCtrl = getNBAMServiceControl();

    To invoke a Container with the V2 service, instantiate:

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

    To invoke multiple Containers with the V2 service, instantiate:

    var nbamServiceCtrl = getNBAMServiceControl()("V2", 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 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
Did you find this content helpful?

Have a question? Get answers now.

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

Ready to crush complexity?

Experience the benefits of Pega Community when you log in.

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us