setAudience

The setAudience method enables you to set the audience ID and level for a visitor.

function callSetAudience(commandsToExecute, callback) {

        var ssId = document.getElementById('sa_sessionId').value;
        var audId = document.getElementById('sa_audienceId').value;
        var audLevel = document.getElementById('sa_audienceLevel').value;
        var params = document.getElementById('sa_parameters').value;

        InteractAPI.setAudience(ssId, getNameValuePairs(audId),audLevel, 
                                      getNameValuePairs(params), callback);

}
  • sessionID - a string identifying the session ID.

  • audienceID - an array of NameValuePairImpl objects that defines the audience ID.

  • audienceLevel - a string that defines the audience level.

  • parameters - NameValuePairImpl objects identifying any parameters that need to be passed with setAudience. These values are stored in the session data and can be used for segmentation.

    You must have a value for every column in your profile. This is a superset of all columns in all the tables defined for the interactive channel and any real-time data. If you have already populated all the session data with startSession or postEvent, you do not need to send new parameters.

  • callback - If the method was successful, the callback function calls onSuccess. If the method failed, the callback function calls onError.

The setAudience method triggers a re-segmentation. The getOffers method waits for re-segmentation to finish before running. Therefore, if you call a setAudience method immediately before a getOffers call, there may be a delay.

The setAudience method also loads the profile data for the audience ID. You can use the setAudience method to force a reload of the same profile data loaded by the startSession method.

The setAudience method reloads the while list and the black list table in an existing session . You can use the setAudience method with the parameters UACIPurgePriorWhiteListOnLoad and UACIPurgePriorBlackListOnLoad to reload the white list table and black list table in an existing session.

By default, when the setAudience method is called, all the contents of the black list is removed. You can set the UACIPurgePriorWhiteListOnLoad and UACIPurgePriorBlackListOnLoad parameters in the setAudience call as follows:

  • If you set UACIPurgePriorBlackListOnLoad= 0, all the contents of the white list table are preserved.

  • If you set UACIPurgePriorWhiteListOnLoad= 1 the contents of the table are removed and the contents of the white list or black list for the audience ID will be loaded from the database. Once completed, re-segmentation will start.

Return value

The runtime server responds to setAudience with a Response object with the following attributes populated:

  • AdvisoryMessages
  • ApiVersion
  • OfferList
  • Profile
  • SessionID
  • StatusCode