Request
The Ad Placement API can be called from either client side or server side.
When using client side implementation, the browser may perform a pre-flight request. If you wish to avoid this, in the request header, use Content-Type: text/plain. This will ensure that the browser qualifies the request as "simple" and therefore skips the pre-flight request.
Also, when calling the API on the client side, IPs are not actually required as it can be difficult to detect IP using frontend and Javascript. Instead, our API detects the IP from the connection when the request is made.
When using server side implementation, in order to ensure correct targeting, the correct IP of the user should be passed explicitly. Otherwise, ads will be targeted for server location and this may cause impressions to be invalidated by an IP mismatch later.
Whether client or server is used, if an IP is passed, it will be prioritised over the one we detect.
In order to perform a request to the ad placement API, you need to pass two objects: user and zones. The request is made in JSON using HTTP POST.
user
| Parameter | Required? | Description |
|---|---|---|
| id | No | The ID of the user |
| ip | Recommended | The user IP address. |
| ua | Yes | The User Agent: A string containing the user's browser/app and device/OS. |
| language | No | Sets the language of the request using the standard two-character ISO code plus an optional 2-character region code. e.g. en-us for United States English. |
| referer | No | The address of the site where the ad will be shown. |
| el | No | The Base64-encoded email of the user. |
| screen_resolution | No | Screen resolution of the device used by user |
| window_orientation | No | This should be "portrait" if the site has a mobile layout and "landscape" if it's a desktop one. |
| gdpr | No | Privacy advised extensions (Object). |
user.gdpr
| Parameter | Description |
|---|---|
| gdpr | This should be 0 if the caller believes that the user is not under GDPR, and 1 if the user is under GDPR . |
| consent | This is the consent string required by the IAB Standards. |
zones
| Parameter | Required? | Description |
|---|---|---|
| id | Yes | The ID of the ad zone |
| sub | No | The Sub ID of the ad zone |
| keywords | No | Any keywords associated to the traffic that might match with a specific type of advertising. If there are no keywords, the URL of the site will be used for matching |
| custom_targeting | No | Custom zone values (Object) |
zones.custom_targeting
| Parameter | Description |
|---|---|
| ex_av | This should be 0 if Undefined, 1 if Age Verified and 2 if Age Not Verified |
Example
It is possible to request many ad zones in a single request. Each zone will have a different ID, as you can see in the example below.
{
"user": {
"id": "abdef8u9",
"ip": "10.42.0.1",
"ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36",
"language": "en-US",
"referer": "https://blabla.com",
"gdpr" : {
"gdpr" : 1,
"consent": "CPAoZRHPArq3hBcADBENBJCgAAAAAAAAAAqIHKQAAOUgAAAA"
}
},
"zones": [
{
"id": 4031007,
"sub": 111,
"keywords": "humour, general"
},
{
"id": 4031015,
"sub": 222
},
{
"id": 4031019,
"sub": 222
}
]
}