LogoLogo
  • Overview
  • What Ads Can Project Agora Commerce Serve?
  • Integration
    • API Introduction
    • Integration Workflow
      • Integration Summary
      • Integration Steps
    • Syncing Data
      • Syncing Data Via File Protocols
    • Syncing Catalog & Products
      • Syncing Catalog and Products Via File
    • Syncing Order Data
      • Syncing Order Data Via API
    • Reporting Clicks and Impressions
    • Integration Checklist
  • Integration Guides
    • HTTP Persistence & Ad Caching
    • Reference
    • Requesting Ads (the "Context" and its Parts)
    • Product Listing Ad Integration Guide
      • Requesting a Category Product Ad
      • Requesting a Search Term Product Ad
      • Requesting a Home Page Product Ad
    • Discovery Product Listing Ad Integration Guide
      • Requesting a Discovery Product Ad
    • Banner Ad Integration Guide
      • Banner Ad Content Standard
      • Requesting a Search Term Banner Ad
      • Requesting a Category Banner Ad
      • Requesting a Home Page Banner Ad
      • The Post Checkout Banner Ad Context
      • Graceful Fallback in the Event That No Ads Are Displayed
    • Banner X Ad Integration Guide
      • Banner X Ad Content Standard
      • Requesting a Category Banner X Ad
      • Requesting a Search Term Banner X Ad
      • Requesting a Home Page Banner X Ad
      • Banner X Ad Reference
      • Graceful Fallback in the Event That No Ads Are Displayed
Powered by GitBook
On this page
  • Homepage: Minimum Viable Context
  • Homepage: Minimum Exemplar Context
  • Search Page and Checkout/Cart Page
  • Category Page
  • 1st Ad request
  • 2nd Ad request
  • Merging results
  • Example
  • Product details Page
  • No DSPL responses case
  1. Integration Guides
  2. Discovery Product Listing Ad Integration Guide

Requesting a Discovery Product Ad

​

Discovery ads require a simple "context' to be sent to Project Agora Commerce. A "context" is a bit of code that defines the conditions under which a product is shown to a customer.

All Discovery ads use thepageType "Category" and product filters:

  • productFilters: "placement:Discovery-Home" for homepage

  • productFilters: "placement:Discovery-Category" for category/subcategory pages

  • productFilters: "placement:Discovery-Search" for search page

  • productFilters: "placement:Discovery-Product" for product detail page

  • productFilters: "placement:Discovery-Checkout" for checkout page

Homepage: Minimum Viable Context

Below are the minimum values needed to generate a Discovery homepage ad:

POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic your_api_key_here
{
    "pageType": "Category",
    "catalogId": "$MY_CATALOG_ID",
    "productFilters": [
      ["placement:Discovery-Home"]
    ],
    "maxNumberOfAds": number
}
curl -iX POST "$BASE_URL/v1/ads/generate" \ 
-H "accept: application/json" \
-H "content-type: application/json" \
-H "Authorization: Basic your_api_key_here" \
-d \
'{
    "pageType": "Category",
    "catalogId": "$MY_CATALOG_ID",
    "productFilters": [
      ["placement:Discovery-Home"]
    ],
    "maxNumberOfAds": number
}'

Homepage: Minimum Exemplar Context

Here is an example of a context for requesting a Discovery homepage ad:

POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic 4ww25f70-b52s-40de-8f29-07b139b5cdc8
{
    "pageType": "Category",
    "catalogId": "628dbe95-2ec9-4e07-881d-3e9f92ab2e0b",
    "productFilters": [
      ["placement:Discovery-Home"]
    ],
    "maxNumberOfAds": 3
}
curl -iX POST "$BASE_URL/v1/ads/generate" \ 
-H "accept: application/json" \
-H "content-type: application/json" \
-H "Authorization: Basic your_api_key_here" \
-d \
'{
    "pageType": "Category",
    "catalogId": "$MY_CATALOG_ID",
    "productFilters": [
      ["placement:Discovery-Home"]
    ],
    "maxNumberOfAds": number
}'

When you successfully request an ad, you receive the following object:

HTTP/2 200
{
    "ads": [
        {
            "id": "display_SEY2W7-VZzspoirbw4ANs-r-w6YyODk5MDQ5UA==",
            "gtin": "catpref--2899049P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516943179Z"
        },
        {
            "id": "display_-hPcUdg5KUQ2sxhE6r0XVN3-iLY5ODkxNTY2UA==",
            "gtin": "catpref--9891566P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516948637Z"
        },
        {
            "id": "display_aGULlK-E_yEiVZ_S_jH9qsH-KhYyOTAyNjIwUA==",
            "gtin": "catpref--2902620P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516953955Z"
        }
    ],
    "banners": [],
    "products": []
}
{
    "ads": [
        {
            "id": "display_SEY2W7-VZzspoirbw4ANs-r-w6YyODk5MDQ5UA==",
            "gtin": "catpref--2899049P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516943179Z"
        },
        {
            "id": "display_-hPcUdg5KUQ2sxhE6r0XVN3-iLY5ODkxNTY2UA==",
            "gtin": "catpref--9891566P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516948637Z"
        },
        {
            "id": "display_aGULlK-E_yEiVZ_S_jH9qsH-KhYyOTAyNjIwUA==",
            "gtin": "catpref--2902620P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516953955Z"
        }
    ],
    "banners": [],
    "products": []
}

Search Page and Checkout/Cart Page

For the "Checkout/Cart page" and the "Search page" the request and responses are exactly the same as in the case of Homepage Discovery Sponsored Listings as shown above with the only difference that the productFilters attribute changes to "placement:Discovery-Checkout" and "placement:Discovery-Search" respectively.

Category Page

In the case of the Category/Subcategory pages there are two ad requests that should take place and the results that will be displayed in the page is the merge of those two requests.

1st Ad request

Specifically the first ad request should be executed like below:

POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic your_api_key_here
{
    "pageType": "Category",
    "catalogId": "$MY_CATALOG_ID",
    "productFilters": [
      ["string","placement:Discovery-Category"]
    ],
    "maxNumberOfAds": number
}
curl -iX POST "$BASE_URL/v1/ads/generate" \ 
-H "accept: application/json" \
-H "content-type: application/json" \
-H "Authorization: Basic your_api_key_here" \
-d \
'{
    "pageType": "Category",
    "catalogId": "$MY_CATALOG_ID",
    "productFilters": [
      ["string","placement:Discovery-Category"]
    ],
    "maxNumberOfAds": number
}'

The string parameter inside the productFilters attribute shall contain only the first-level parent category of the category path in which the specific category of the category page belongs.

For example the ad request inside the category Cream which has the below category path: Woman>Face>Cream (the first parent category is "Woman") should be like this:

POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic 4ww25f70-b52s-40de-8f29-07b139b5cdc8
{
    "pageType": "Category",
    "catalogId": "628dbe95-2ec9-4e07-881d-3e9f92ab2e0b",
    "productFilters": [
      ["Woman","placement:Discovery-Category"]
    ],
    "maxNumberOfAds": 3
}
curl -iX POST "$BASE_URL/v1/ads/generate" \ 
-H "accept: application/json" \
-H "content-type: application/json" \
-H "Authorization: Basic 4ww25f70-b52s-40de-8f29-07b139b5cdc8" \
-d \
'{
    "pageType": "Category",
    "catalogId": "628dbe95-2ec9-4e07-881d-3e9f92ab2e0b",
    "productFilters": [
      ["Woman","placement:Discovery-Category"]
    ],
    "maxNumberOfAds": 3
}'

When you successfully request an ad, you receive the following object:

HTTP/2 200
{
    "ads": [
        {
            "id": "display_SEY2W7-VZzspoirbw4ANs-r-w6YyODk5MDQ5UA==",
            "gtin": "catpref--2899049P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516943179Z"
        },
        {
            "id": "display_-hPcUdg5KUQ2sxhE6r0XVN3-iLY5ODkxNTY2UA==",
            "gtin": "catpref--9891566P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516948637Z"
        },
        {
            "id": "display_aGULlK-E_yEiVZ_S_jH9qsH-KhYyOTAyNjIwUA==",
            "gtin": "catpref--2902620P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516953955Z"
        }
    ],
    "banners": [],
    "products": []
}
{
    "ads": [
        {
            "id": "display_SEY2W7-VZzspoirbw4ANs-r-w6YyODk5MDQ5UA==",
            "gtin": "catpref--2899049P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516943179Z"
        },
        {
            "id": "display_-hPcUdg5KUQ2sxhE6r0XVN3-iLY5ODkxNTY2UA==",
            "gtin": "catpref--9891566P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516948637Z"
        },
        {
            "id": "display_aGULlK-E_yEiVZ_S_jH9qsH-KhYyOTAyNjIwUA==",
            "gtin": "catpref--2902620P",
            "discount": {
                "amount": 0,
                "minPrice": 0,
                "maxPerCustomer": 0
            },
            "expiry": "2019-12-10T01:46:07.516953955Z"
        }
    ],
    "banners": [],
    "products": []
}

2nd Ad request

The second ad request should be executed like below:

POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic your_api_key_here
{
    "pageType": "Category",
    "catalogId": "$MY_CATALOG_ID",
    "productFilters": [
      ["placement:Discovery-Category"]
    ],
    "maxNumberOfAds": number
}
curl -iX POST "$BASE_URL/v1/ads/generate" \ 
-H "accept: application/json" \
-H "content-type: application/json" \
-H "Authorization: Basic your_api_key_here" \
-d \
'{
    "pageType": "Category",
    "catalogId": "$MY_CATALOG_ID",
    "productFilters": [
      ["placement:Discovery-Category"]
    ],
    "maxNumberOfAds": number
}'

This request as seen above will have only the static filter placement:Discovery-Category as in the case of the homepage, checkout and search page DSPL requests.

Merging results

The final part is to merge the above responses in order to populate the Discovery Sponsored Product Listings positions inside the Discovery grid.

Specifically all the positions inside the Discovery Grid should be populated with the ad responses that you have get from the 1st ad request .

In case there are no ad responses for the 1st ad request, the positions of the Discovery Grid shall be populated with the responses from the 2nd ad request.

In addition if there are not enough ad responses to fill all the agreed positions( from the ad proposal) in the Discovery Grid from the 1st ad request then the rest of the positions will have to be populated with the responses from the 2nd ad request.

Please note that in case there are duplicate ad responses from the 1st and 2nd ad requests (as the 2nd request is more generic and may contain also items which are included in the 1st one too) we want to serve them only once.

Example

For example in case in the category page according to the ad proposal 8 positions should be filled with DSPL ads in the Discovery Grid, then the 1st ad request should be made and the 2nd one with maxNumberOfads:8

In case the 1st ad response will return only 3 items, then the first three items of the Discovery Grid shall be populated with the 3 items of the 1st ad response while the remaining 5 with the items returned as a response from the 2nd ad response

Product details Page

In the case of the Product details pages there are two ad requests that should take place and the results that will be displayed in the page is the merge of those two requests.

The process is exactly the same as described above in the Category/Subcategory with the only change of the static filter in the request which will now be: placement:Discovery-Product

Keep in mind that in the 1st ad request, the first level parent category of the category path in which this product belongs should be included in the request.

No DSPL responses case

An important note for the cases there are no Discovery Product Listings items in response of the DSPL ad requests:

For the cases when there is no discovery sponsored listing ad to serve (because of no active campaigns), you will have to fill the positions in the discovery grid with organic items and remove the sponsored labeling.

​

PreviousDiscovery Product Listing Ad Integration GuideNextBanner Ad Integration Guide

Last updated 4 years ago