DocumentationTargetTarget Developer Guide

Get Offers (Node.js)

Last update: July 17, 2023
  • Topics:
  • APIs/SDKs

CREATED FOR:

  • Developer

Description

getOffers() is used to execute a decision and retrieve an experience from Adobe Target.

Method

getOffers

TargetClient.getOffers(options: Object): Promise

Parameters

The options object has the following structure:

NameTypeRequiredDefaultDescription
RequestObjectYesNoneConforms to the Target Delivery API request
visitorCookieStringNoNoneECID (VisitorId) cookie
targetCookieStringNoNoneTarget cookie
targetLocationHintStringNoNoneTarget location hint
consumerIdStingNoNoneconsumerIds for Analytics for Target (A4T) stitching
CustomerIdsArrayNoNoneCustomer IDs in VisitorId-compatible format
sessionIdStringNoNoneUsed for linking multiple Target requests
visitorObjectNonew VisitorIdSupply an external VisitorId instance

Promise

Promise returned has the following structure:

NameTypeDescription
requestObjectTarget Delivery API request
responseObjectTarget Delivery API response
visitorStateObjectObject that should be passed to Visitor API getInstance()
targetCookieObjectTarget cookie
targetLocationHintCookieObjectTarget location hint cookie
analyticsDetailsArrayAnalytics payload, in case of client-side Analytics usage
responseTokensArrayA list of Response tokens.
traceArrayAggregated trace data for all request mboxes/views
statusObjectAn object containing the status of the response.
decisioningMethodStringDetermines which decisioning method to use (on-device, server-side, hybrid)

targetCookie and targetLocationHintCookie objects used for passing data back to the browser have the following structure:

NameTypeDescription
nameStringCookie name
valueAnyCookie value, the will be converted to string
maxAgeNumberThe maxAge option is a convenience for setting expires relative to the current time in seconds

The status object used for indicating the status of the target response has the following structure:

NameTypeDescription
statusNumberHTTP status code
messageStringA message about the response. For instance, it may indicate if the response was decided on-device or server-side
remoteMboxesArrayWhen decisioning Method is on-device, an array of mbox names that could not be fully decided on-device is given. In other words, a Target Delivery API request is needed.

Example

Node.js

const TargetClient = require("@adobe/target-nodejs-sdk");
const CONFIG = {
  client: "acmeclient",
  organizationId: "1234567890@AdobeOrg"
};

const targetClient = TargetClient.create(CONFIG);

const request = {
    context: {channel: "web"},
    execute: {
        mboxes: [{
            name: "a1-serverside-ab",
            index: 1
        }]
}};

const response = await targetClient.getOffers({ request });
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3