node package manager

@adobe/target-node-client

Marketing Cloud Client

Marketing Cloud Client allows clients to get execute requests against Adobe edge network and retrieve personalized content that can be used to personalize an user experience. Behind the scenes Marketing Cloud Client wraps two of the Adobe solutions, MCID and Target.

Marketing Cloud Client usage

Marketing Cloud Client is pretty straightforward to use. Here are the steps:

  1. Create an Marketing Cloud Client instance
  2. Retrieve variation
  3. Apply the personalized content extracted from variation

Here is a very simple example:

const options = {
  config: {
    client: "foo",
    organizationId: "foo@AdobeOrg",
    timeout: 5000
  }
};
const expClient = MarketingCloudClient.create(options);
const request = {
  mbox : "some-mbox"
};
 
expClient.getVariation(request).then(variation => console.log('Variation', variation));

Marketing Cloud Client API

The Marketing Cloud Client has the following API.

  1. MarketingCloudClient.getVisitorCookieName(organizationId: string): string - used to retrieve MCID cookie name
  2. MarketingCloudClient.getTargetCookieName(): string - used to retrieve Target cookie name
  3. MarketingCloudClient.getTargetEdgeClusterCookieName(): string - used to retrieve Target edge cluster cookie name
  4. MarketingCloudClient.create(options: Object): MarketingCloudClient - creates an instance of Marketing Cloud Client.

The options object has the following structure:

Name Required Default Description
config Yes None General config
targetCookie No None Target cookie
targetEdgeClusterCookie No None Target edge cluster cookie
visitorCookie No None Visitor cookie

The config object should have the following structure

Name Required Default Description
client Yes None Target client
organizationId Yes None Organization ID
timeout No None Target request timeout
secure No true Target request over HTTP or HTTPS
  1. MarketingCloudClient.getVariation(request: Object): Promise - retrieves a variation. The request object uses the same JSON structures that can be found here: https://www.adobe.io/apis/marketingcloud/target/docs/reference/delivery.html. The response promise wraps a variation.

The variation result object has the following structure:

Name Type Description
targetCookie Object Object with {name, value, expires}, that should be used to save Target cookie
targetEdgeClusterCookie Object Object with {name, value, expires}, that should be used to save Target edge cluster cookie. The cluster is used to ensure that client side and server side are hitting the same Target edge
visitorState Object Object that contains SDID and other details used by Visitor API
content String or Object Personalized content, can be string or object