Skip to main content

Request ads and render them

Send one ad request per page view and render the ads that come back. Sponsored Display and Sponsored Products use the same endpoint.

Every ad request needs the domain_id, the API key, the placements with their keys, and a session_id. What else you send depends on the page.

POST /server/v2/ads · Full reference

PageAdd to the request
Search resultssearch (the shopper’s query) and the listed products
Category pagecategory (or your category_id) and the listed products
Product pageproducts, with the viewed product first
Homepagenothing else, unless the page lists products

Pick a page below. The sample updates in your chosen language.

curl --request POST 'https://xxx.edge-stage.gowit.app/server/v2/ads' \
--header 'Authorization: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"domain_id": 1001,
"session_id": "ec07083a-8bf812",
"placements": [
{
"placement_id": 1
}
],
"search": "hiking boots",
"products": [
{
"id": "P30005",
"category": "Outdoor>Footwear>Hiking Sandals"
},
{
"id": "P30003",
"category": "Outdoor>Footwear"
},
{
"id": "P30001",
"category": "Outdoor>Footwear"
}
],
"page_number": 0
}'

Request fields​

FieldTypeRequiredDescription
domain_idintegerYesYour domain id: the number of your market on GoWit. GoWit shares it with your host and keys. Stage and production use their own values.
session_idstringYesThe shopper's session id. Keep it stable for the whole attribution window: impressions, clicks and sales are matched to ads by it.
placementsobject[]YesThe slots on this page that should be filled. Each is answered in order.
productsobject[]When listing pagesThe products listed organically on the page, in page order, each with its category. GoWit uses them for relevance. On a product detail page put the viewed product first. Leave it out when the page lists no products (e.g. a homepage).
searchstringWhen on search pagesThe shopper's search query. Drives keyword targeting.
categorystringWhen on category pagesThe exact category path of the page, e.g. Outdoor>Footwear.
category_idstringNoYour own category code, accepted in place of category. When the code is unknown, category is used.
page_numberintegerNoResults page, starting at 0. Lets ads continue in ranked order on page 2, 3, … Default 0.
customerobjectNoShopper context. Every field is optional and a bad value is dropped, never refused.
session_id

Keep session_id stable for the whole attribution window. Sales are matched to ads by it.

Show each returned product in its slot, using product_id and seller_ref. product_id is the product’s sku, or its id when no sku was sent. Sale events still name the product by its id.

{
"placements": [
{
"ads": [
{ "ad_id": "AbX3kQ9rT2vLm8...wP4n", "seller_ref": "ADV003", "label": "Sponsored", "position": 1, "product_id": "P30007", "products": null, "redirects": null },
{ "ad_id": "Ac7Hn2sW5xBq1...tR8k", "seller_ref": "ADV002", "label": "Sponsored", "position": 2, "product_id": "P30017", "products": null, "redirects": null }
],
"placement_id": 1
}
],
"response_id": "e5c257b0-d40d-4f02-81b7-b0599eee6db3"
}

Build the banner from img_url, its size and its redirect. When HTML creatives are on for your market, an html field comes too; render it when it is there.

{
"placements": [
{
"ads": [
{
"ad_id": "AbX3kQ9rT2vLm8...wP4n",
"seller_ref": "ADV001",
"creative_id": 6438,
"img_url": "https://cdn.example.com/creatives/7f3c/banner-300x250.png",
"label": "Sponsored",
"position": 1,
"products": [{ "sku": "P30001", "name": "Waterproof Hiking Boots", "price": 129.99 }],
"redirect": { "type": "CUSTOM", "url": "https://www.example.com/outdoor" },
"size": "300x250"
}
],
"placement_id": 5
}
],
"response_id": "69cd47e3-ac75-4bc4-b621-2fea4b865f87"
}

A 204 with an empty body means no placement got an ad. A 200 leaves out each placement with no ad. On a 204 or a timeout, keep the slot empty or show your own content.

ad_id

The ad_id is a sealed token. Send it back in events exactly as it came, without changing it.

Timeouts

Ads are answered within about 200 ms. Set your client timeout close to that and never hold the page for an ad.

Checklist

  • An ad request for the sponsored display format returns an ad response. (Retailer)
  • An ad request for the sponsored products format returns an ad response. (Retailer)
  • Impression counts in the Onsite app rise for the returned ads. (Retailer)