Edit in GitHubLog an issue

adobe.target.getOffers() - at.js 2.x

This function lets you retrieve multiple offers by passing in multiple mboxes. Additionally, multiple offers can be retrieved for all views in active activities.

KeyTypeRequired?Description
consumerIdStringNoDefault value is client's global mbox if not provided. This key is used to generate the supplemental data ID (SDID) used for A4T integration.
When using getOffers(), each call generates a new SDID. If you have multiple mbox requests on the same page, and want to preserve the SDID (so that it matches the SDID from the target-global-mbox and the Adobe Analytics SDID), use the consumerId parameter.
If getOffers() includes three mboxes (named "mbox1", "mbox2", and "mbox3"), include: consumerId: "mbox1, mbox2, mbox3" in the getOffers() call.
decisioningMethodStringNo“server-side”, “on-device”, “hybrid”
requestObjectYesSee Requests table below.
timeoutNumberNoRequest timeout. If not specified the default at.js timeout is used.

Request#

Field nameRequired?LimitationsDescription
request > idNoOne of tntId, thirdPartyId, or marketingCloudVisitorId is required.
Request > id > thirdPartyIdNoMaximum size = 128.
Request > experienceCloudNo
Request > experienceCloud > analyticsNoAdobe Analytics integration
Request > experienceCloud > analytics > loggingNoThe following must be implemented on page:
  • Visitor ID Service
  • Appmeasurement.js
The following values are supported:
client_side: When specified, an analytics payload will be returned to the caller which should be used to send to Adobe Analytics via the Data Insertion API.
server_side: This is the default value where the Target and Analytics backend will use the SDID to stitch the calls together for reporting purposes.
Request > prefetchNo
Request > prefetch > viewsNoMaximum count 50.
Name not blank.
Name length <= 128.
Value length <= 5000.
Name should not start with "profile".
Not allowed names: "orderId", "orderTotal", "productPurchasedId".
Pass in parameters to be used to retrieve relevant views in active activities.
Request > prefetch > views > profileParametersNoMaximim count 50.
Name not blank.
Name length <= 128.
Value length <= 5000.
Accepts String values only.
Name should not start with "profile".
Pass in profile parameters to be used to retrieve relevant views in active activities.
Request > prefetch > views > productNo
Request > prefetch > views > product -> idNoNot blank.
maximum size = 128.
Pass in product IDs to be used to retrieve relevant views in active activities.
Request > prefetch > views > product > categoryIdNoNot blank.
maximum size = 128.
Pass in product category IDs to be used to retrieve relevant views in activities.
Request > prefetch > views > orderNo
Request > prefetch > views > order > idNoMaximum length = 250.Pass in order IDs to be used to retrieve relevant views in in active activities.
Request > prefetch > views > order > totalNoTotal >= 0.Pass in order totals to be used to retrieve relevant views in active activities.
Request > prefetch > views > order > purchasedProductIdsNoNo blank values.
Each value's max length 50.
Concatenated and separated by comma.
Product IDs total length <= 250.
Pass in purchased product IDs to be used to retrieve relevant views in active activities.
Request > executeNo
Request > execute > pageLoadNo
Request > execute > pageLoad > parametersNoMaximum count 50.
Name not blank.
Name length <= 128.
Value length <= 5000.
Accepts String values only.
Name should not start with "profile".
Not allowed names: "orderId", "orderTotal", "productPurchasedId".
Retrieve offers with specified parameters when page loads.
Request > execute > pageLoad > profileParametersNoMaximum count 50.
Name not blank.
Name length <= 128.
Value length <=256.
Name should not start with "profile".
Accepts String values only.
Retrieve offers with specified profile parameters when page loads.
Request > execute > pageLoad > productNo
Request > execute > pageLoad > product -> idNoNot blank.
Maximum size = 128.
Retrieve offers with specified product IDs when page loads.
Request > execute > pageLoad > product > categoryIdNoNot blank.
Maximum size = 128.
Retrieve offers with specified product category IDs when page loads.
Request > execute > pageLoad > orderNo
Request > execute > pageLoad > order > idNoMaximum length = 250.Retrieve offers with specified order IDs when page loads.
Request > execute > pageLoad > order > totalNo>= 0.Retrieve offers with specified order totals when page loads.
Request > execute > pageLoad > order > purchasedProductIdsNoNo blank values.
Each value's max length 50.
Concatenated and separated by comma.
Product IDs total length <= 250.
Retrieve offers with specified purchased product IDs when page loads.
Request > execute > mboxesNoMaximum size = 50.
No null elements.
Request > execute > mboxes>mboxYesNot blank.
No '-clicked' suffix.
Maximum size = 250.
Allowed characters: `'-, .\/=:;&!@#$%^&*()+
?~[]{}'`
Request > execute > mboxes>mbox>indexYesNot null.
Unique.
>= 0.
Note that the index does not represent the order in which the mboxes will be processed. Same as in a web page with several regional mboxes, the order in which they will be processed cannot be specified.
Request > execute > mboxes > mbox > parametersNoMaximum count = 50.
Name not blank.
Name length <= 128.
Accepts String values only.
Value length <= 5000.
Name should not start with "profile."
Not allowed names: "orderId", "orderTotal", "productPurchasedId".
Retrieve offers for a given mbox with the specified parameters.
Request > execute > mboxes>mbox>profileParametersNoMaximum count = 50.
Name not blank.
Name length <= 128.
Accepts String values only.
Value length <=256.
Name should not start with "profile."
Retrieve offers for a given mbox with the specified profile parameters.
Request > execute > mboxes>mbox > productNo
Request > execute > mboxes > mbox > product > idNoNot blank.
Maximum size = 128.
Retrieve offers for a given mbox with the specified product IDs.
Request > execute > mboxes > mbox > product > categoryIdNoNot blank.
Maximum size = 128.
Retrieve offers for a given mbox with the specified product category IDs.
Request > execute > mboxes > mbox > orderNo
Request > execute > mboxes>mbox > order > idNoMaximum length = 250.Retrieve offers for a given mbox with the specified order IDs.
Request > execute > mboxes > mbox > order > totalNo>= 0.Retrieve offers for a given mbox with the specified order totals.
Request > execute > mboxes > mbox > order > purchasedProductIdsNoNo blank values.
Each value's maximum length = 50.
Concatenated and separated by comma.
Product ids total length <= 250.
Retrieve offers for a given mbox with the specified order purchased product IDs.

Call getOffers() for all views#

Copied to your clipboard
1adobe.target.getOffers({
2 request: {
3 prefetch: {
4 views: [{}]
5 }
6 }
7});

Call getOffers() to make an on-device decisioning#

Copied to your clipboard
1adobe.target.getOffers({
2
3 decisioningMethod:"on-device",
4  request: {
5    execute: {
6      mboxes: [
7        {
8          index: 0,
9          name: "homepage"
10        }
11      ]
12    }
13}
14});

Call getOffers() to retrieve the latest views with the passed-in parameters and profile parameters#

Copied to your clipboard
1adobe.target.getOffers({
2 request: {
3 "prefetch": {
4 "views": [
5 {
6 "parameters": {
7 "ad": "1"
8 },
9 "profileParameters": {
10 "age": 23
11 }
12 }
13 ]
14 }
15 }
16});

Call getOffers() to retrieve mboxes with parameters and profile parameters passed-in.#

Copied to your clipboard
1adobe.target.getOffers({
2 request: {
3 execute: {
4 mboxes: [
5 {
6 index: 0,
7 name: "first-mbox"
8 },
9 {
10 index: 1,
11 name: "second-mbox",
12 parameters: {
13 a: 1
14 },
15 profileParameters: {
16 b: 2
17 }
18 }
19 ]
20 }
21 }
22});

Call getOffers() to retrieve the analytics payload from the client side#

Copied to your clipboard
1adobe.target.getOffers({
2 request: {
3 experienceCloud: {
4 analytics: {
5 logging: "client_side"
6 }
7 },
8 prefetch: {
9 mboxes: [{
10 index: 0,
11 name: "a1-serverside-xt"
12 }]
13 }
14 }
15 })
16 .then(console.log)

Response:

Copied to your clipboard
1{
2 "prefetch": {
3 "mboxes": [{
4 "index": 0,
5 "name": "a1-serverside-xt",
6 "options": [{
7 "content": "<img src=\"http://s7d2.scene7.com/is/image/TargetAdobeTargetMobile/L4242-xt-usa?tm=1490025518668&fit=constrain&hei=491&wid=980&fmt=png-alpha\"/>",
8 "type": "html",
9 "eventToken": "n/K05qdH0MxsiyH4gX05/2qipfsIHvVzTQxHolz2IpSCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==",
10 "responseTokens": {
11 "profile.memberlevel": "0",
12 "geo.city": "bucharest",
13 "activity.id": "167169",
14 "experience.name": "USA Experience",
15 "geo.country": "romania"
16 }
17 }],
18 "analytics": {
19 "payload": {
20 "pe": "tnt",
21 "tnta": "167169:0:0|0|100,167169:0:0|2|100,167169:0:0|1|100"
22 }
23 }
24 }]
25 }
26}

The payload can then be forwarded to Adobe Analytics via the Data Insertion API.

Fetch and render data from multiple mboxes via getOffers() and applyOffers()#

at.js 2.x lets you fetch multiple mboxes via the getOffers() API. You can also fetch data for multiple mboxes and then use applyOffers() to render the data in different locations identified by a CSS selector.

The following example shows a simple HTML page with at.js 2.x implemented:

Copied to your clipboard
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="utf-8">
5 <title>at.js 2.x, multiple selectors and multiple mboxes</title>
6 <script src="at.js"></script>
7</head>
8<body>
9 <div id="container1">Default content 1</div>
10
11 <div id="container2">Default content 2</div>
12
13 <div id="container3">Default content 3</div>
14</body>
15</html>

Assume that you have three containers that you want to modify via content received from Target. You can construct a single request for three mboxes in which each mbox has some content to render into the respective container.

The request and rendering code might look like the following example:

Copied to your clipboard
1adobe.target.getOffers({
2 request: {
3 prefetch: {
4 mboxes: [
5 {
6 index: 0,
7 name: "mbox1"
8 },
9 {
10 index: 1,
11 name: "mbox2"
12 },
13 {
14 index: 2,
15 name: "mbox3"
16 }
17 ]
18 }
19 }
20})
21.then(response => {
22 // get all mboxes from response
23 const mboxes = response.prefetch.mboxes;
24 let count = 1;
25
26 mboxes.forEach(el => {
27 adobe.target.applyOffers({
28 selector: "#container" + count,
29 response: {
30 prefetch: {
31 mboxes: [el]
32 }
33 }
34 });
35
36 count += 1;
37 });
38});

In the request > prefetch > mboxes section, there are three different mboxes. If the request completed successfully, you receive the response for each mbox from response > prefetch > mboxes. After you have the responses and the locations you want to use for rendering, you can invoke applyOffers() to render the content retrieved from Target. In this example we have the following mapping:

  • mbox1 > CSS selector #container1
  • mbox2 > CSS selector #container2
  • mbox3 > CSS selector #container3

This example uses the count variable to construct the CSS selectors. In a real-life scenario you could use a different mapping between the CSS selector and mbox.

Note that this example uses prefetch > mboxes, but you could also use execute > mboxes. Ensure that if you use prefetch in getOffers(), you should also use prefetch in the applyOffers() invocation.

Call getOffers() to perform a pageLoad#

The following example shows you how to perform a pageLoad using getOffers() with at.js 2.x

Copied to your clipboard
1adobe.target.getOffers({
2 request: {
3 execute: {
4 pageLoad: {
5 parameters: {}
6 }
7 }
8 }
9});
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.