Requesting a Category Product Ad

Page Category ads require a simple "context' to be sent to CitrusAd. A "context" is a bit of code that defines the conditions under which a product is shown to a customer.

Minimum Viable Context:

Below are the minimum values needed to generate a search term ad:

HTTP
cURL
HTTP
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"]
],
"maxNumberOfAds": number
}
cURL
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"]
],
"maxNumberOfAds": number
}'

Exemplar Context

Here is an example of a context for the pageType "Category":

HTTP
cURL
HTTP
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": [
["category:computers"]
],
"maxNumberOfAds": 3
}
cURL
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": [
["category:computers"]
],
"maxNumberOfAds": 3
}'

What Happens when an Ad Is Successfully Requested

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

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

No customer information or cart items are necessary in this simple context. The simple context consists only of necessary filters.

The discount and products fields are legacy and can be ignored

Filtered Browsing

When a user filters their browsing deeper into subcategories, you are able to serve ads relevant to their filters using more productFilters in the context.

In this example, the user has navigated to the Computers category, and browsed further to "Laptops" and "Windows" categories. This is a new request and considered by CitrusAd as a new page, and new set of ads. Even in the rare event the ads served are identical to the unfiltered results.

HTTP
cURL
HTTP
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": [
["category:computers","category:Laptops","category:Windows"]
],
"maxNumberOfAds": 3
}
cURL
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": [
["category:computers","category:Laptops","category:Windows"]
],
"maxNumberOfAds": 3
}'

As your customers filter deeper in their searches, your request will include more product filters

HTTP
cURL
HTTP
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": [
["category:computers","category:Laptops","category:Windows", "delivery:DeliveryOnly", "pricerange:$250-$500"]
],
"maxNumberOfAds": 3
}
cURL
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": [
["category:computers","category:Laptops","category:Windows", "delivery:DeliveryOnly", "pricerange:$250-$500"]
],
"maxNumberOfAds": 3
}'

What Happens when an Ad Is Successfully Requested

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

HTTP
cURL
HTTP
HTTP/2 200
{
"ads": [
{
"id": "display_ZFwfo0Mi2AhFBxUBHpXnICvV2j8zNTcxNzExUA==",
"gtin": "3571711P",
"discount": {
"amount": 0,
"minPrice": 0,
"maxPerCustomer": 0
},
"expiry": "2019-12-10T01:51:07.936105529Z"
},
{
"id": "display_VpFfnPOnaG4MZh43ckQjufmGAzwzNTcxOTkyUA==",
"gtin": "3571992P",
"discount": {
"amount": 0,
"minPrice": 0,
"maxPerCustomer": 0
},
"expiry": "2019-12-10T01:51:07.936111787Z"
},
{
"id": "display_vRHRnkTXbbssVwiem8jDrmOp2FM2Mzg3NTkyUA==",
"gtin": "6387592P",
"discount": {
"amount": 0,
"minPrice": 0,
"maxPerCustomer": 0
},
"expiry": "2019-12-10T01:51:07.936117921Z"
},
],
"banners": [],
"products": []
}
cURL
{
"ads": [
{
"id": "display_ZFwfo0Mi2AhFBxUBHpXnICvV2j8zNTcxNzExUA==",
"gtin": "3571711P",
"discount": {
"amount": 0,
"minPrice": 0,
"maxPerCustomer": 0
},
"expiry": "2019-12-10T01:51:07.936105529Z"
},
{
"id": "display_VpFfnPOnaG4MZh43ckQjufmGAzwzNTcxOTkyUA==",
"gtin": "3571992P",
"discount": {
"amount": 0,
"minPrice": 0,
"maxPerCustomer": 0
},
"expiry": "2019-12-10T01:51:07.936111787Z"
},
{
"id": "display_vRHRnkTXbbssVwiem8jDrmOp2FM2Mzg3NTkyUA==",
"gtin": "6387592P",
"discount": {
"amount": 0,
"minPrice": 0,
"maxPerCustomer": 0
},
"expiry": "2019-12-10T01:51:07.936117921Z"
},
],
"banners": [],
"products": []
}

Using Session Ids for Order Attribution

If you are planning on using sessionIds as your method of order attribution, you will need to send a sessionId in your ad generation requests:

HTTP
cURL
HTTP
POST $BASE_URL/v1/ads/generate HTTP/1.1
accept: application/json
content-type: application/json
Authorization: Basic your_api_key_goes_here
{
"pageType": "Category",
"catalogId": "628dbe95-2ec9-4e07-881d-3e9f92ab2e0b",
"productFilters": [
["category:computers","category:Laptops","category:Windows", "delivery:DeliveryOnly", "pricerange:$250-$500"]
],
"sessionId": "23dn3923-323d",
"maxNumberOfAds": 3
}
cURL
curl -iX POST "$BASE_URL/v1/ads/generate" \
-H "accept: application/json" \
-H "content-type: application/json" \
-H "Authorization: Basic your_api_key_goes_here" \
-d \
'{
"pageType": "Category",
"catalogId": "628dbe95-2ec9-4e07-881d-3e9f92ab2e0b",
"productFilters": [
["category:computers","category:Laptops","category:Windows", "delivery:DeliveryOnly", "pricerange:$250-$500"]
],
"sessionId": "23dn3923-323d",
"maxNumberOfAds": 3
}'

If you are unsure of the strings displayed on this page. Take a look at the Reference page.