Suppose there are 3 ads that my system can deliver. If I want all three to be delivered roughly the same amount of times over the course of a week, I can just choose a random number between 1-3 each time, then deliver ad 1, 2, or 3.
var ads = [
{id: 1, img: '/img/ad01.jpg'},
{id: 2, img: '/img/ad02.jpg'},
{id: 3, img: '/img/ad03.jpg'},
];
var rand = Math.random() * ads.length | 0;
// v------ This ad will be delivered ~33% of the time
return ads[rand];
What I need to do
1. Each ad is to be scheduled to run between some date range
2. I need to deliver each ad a different percentage of the time, such as:
var share = [
{adId: 1, share: 20}, // <----- adId 1 is shown ~20% of the time
{adId: 2, share: 30},
{adId: 3, share: 50}
];
3. Some ads may have further constrains, such as not being shown between certain hours, days of the week, etc.
Challenges I've faced
- I don't know necessarily how many page views I'll generate during the time frame each ad is scheduled to run.
- I don't know how to boost the amount of impressions one ad gets over the others based on its current pacing, and yet more or less guarantee that it receives the percentage of page views it was configured for.
Edit
To clarify,
I am storing all of this information in the server. That's where all the ads are stored, along with all of the settings such as when they are delivered, what percentage of the time, etc. What I'm asking is how to calculate their current pacing, and adjust when each ad is delivered.