How to use Unique Delivery via API
Unique Delivery is an optional feature that can be enabled in zones. When it's enabled, each campaign assigned to that zone will be selected to serve only once per page. This is particularly useful when you want to have multiple instances of the same zone on the same webpage. For more information, read Unique Delivery.
Enabling Unique Delivery on a zone is not enough. You must also add a couple of parameters to your JSON Ad API requests to implement the feature.
Unique Delivery Parameters
The pid
or Page ID is a random integer that represents one page load. It should be the same for every ad request from the same page load. When you use AdButler's zone tags to request for ads, AdButler automatically generates a value for this parameter. However, when requesting for ads using our API, you must provide the value of pid
yourself. You will then use that same pid
when requesting for multiple instances of the same zone.
The second parameter is place
. This is an integer that represents a unique instance of the same zone on the page. The first instance of a zone should have a place
value of 0, the second instance should have a value of 1, and so on.
These parameters tell AdButler to serve different ads to different instances of the same zone on a single page load.
Requesting via GET
Here's an example of the same zone being called twice on the same page to properly implement Unique Delivery. Note how pid
is the same in both requests while place
is incremented by one:
https://ads.domain.com/adserve/;ID=171230;size=300x250;setID=373469;type=json;pid=123456;place=0;click=CLICK_MACRO_PLACEHOLDER
https://ads.domain.com/adserve/;ID=171230;size=300x250;setID=373469;type=json;pid=123456;place=1;click=CLICK_MACRO_PLACEHOLDER
;click=CLICK_MACRO_PLACEHOLDER
to make sure the request is read correctly. Everything after the ;click=
parameter is read as one value. If you do not have a click tracking link, we recommend removing the ;click=
parameter. Doing so will also make it easier to add or remove other parameters without affecting your ad's click-throughs.Requesting via POST
You can also implement Unique Delivery via POST. As when requesting via GET, the pid
is the same in both requests while place
is incremented by one:
Example:
POST https://ads.domain.com/adserve
{
"ID": 171230,
"size": "300x250",
"setID": 373469,
"type": "json",
"pid": 123456,
"place": 0
}
POST https://ads.domain.com/adserve
{
"ID": 171230,
"size": "300x250",
"setID": 373469,
"type": "json",
"pid": 123456,
"place": 1
}