views:

194

answers:

2

A client I'm creating a site for wants a custom advertising "engine". The plan is to have a few ads on the site and fill the rest with Google Adsense until all the spots are full.

My problem is how to determine which ad to dipslay. (Assume for now that I only have 1 ad placement.) My thinking was I'd have a table with:

  • year
  • month
  • impressions for the month (0 for unlimited)
  • used impressesion
  • clients
  • HTML code to display ad

I could do something like to get the ads:

SELECT * 
FROM ad 
WHERE impressions > used_impressions 
    OR impressesions = 0 
ORDER BY RAND() 
LIMIT 1

But, say I have 3 ads:

  • 1 ad -- 5000 impressions
  • 1 ad -- 5000 impressions
  • Google Adsense filling the reaminder of the sites hits

Statistically speaking all 3 ads would be displayed an equal number of times. By the end of the first week and 15000 hits on the site, the first 2 ads would have used all of their impressions and the remaining 3+ weeks of the month and not be displayed again; only Google Adsense would be displayed.

How do I space out the ads so they are spread out over the month?

I am using LAMP.

+3  A: 

Darryl,

I would suggest breaking the ad impressions down by day, so that

1 ad -- 5000/(monthsToDisplay/30)

This will give you a number of impressions you need to serve per day, and should help distribute things nicely over the weeks. So lets assume you have these variables or database fields:

totalImpressions = 5000;

dailyImpressions = totalImpressions/(monthsToDisplay/30)

Then you could do something like:

SELECT * FROM ad WHERE (totalImpressions > used_impressions AND dailyImpressions > used_dailyImpressions) OR impressesions = 0 ORDER BY RAND() LIMIT 1

Hope this made sense - it's early morning here, but I will check back later!

Berti

Ignoring all the other weighting factors that they have to deal with, I believe that this idea of daily targets is pretty much how the big ad networks deal with this (except typically with hourly targets)
stevemegson
Also, it's better to calculate your target each day based on the impressions and days left rather than use a fixed figure all month. That way, if you have a day of low traffic you'll automatically upweight the ads the next day to catch up.
stevemegson
Ignoring all the other weighting factors that they have to deal with, I believe that this idea of daily targets is pretty much how the big ad networks deal with this (except typically with hourly targets)
stevemegson
Would you add an additional field for impressions for that day and update everytime you arrive at a new day? Or would you use a separate table to log the impressions?
Darryl Hein
A: 

You are talking about AdServing type of technology. There are various ways to determine which ad should be shown.

The Event delivery scenario described above is generally called "Even Flighting". Meaning, that an ad will be served evenly for the duration of the campaign. This is not always best. Sometimes advertisers just want delivery.

"Even Flighting" should not be implemented on its own. You should first implement "Frequency Capping". This means that the same ad is not served to the same person more than a set amount of times. Example, if a user doesn't click on an ad after 5 times of seeing it, they are just not going to click. In this event, you should serve another ad.

Combining this method, you would determine how many impressions you need to serve for the day.. then on a per user basis.. determine how many times the user has seen the ad. If they are eligable to see it again, then show it.. otherwise.. show adsense.

However, you would be better off suggesting a free ad server like Google Ad Manager or OpenX. They have already solved all of these problems and there is no point re-inventing the wheel.

majestiq