Building an AdNetwork
Another wekeend project from NimbleWorks was to build an Advertsing network. Turns out it's incredibly simple todo if you don't want any features.
Inpired by the best niche advertising networks out there at the moment the plan was to build a single image per page, with 140 charachters of text and a single link.
We need three things for this to work:
- Inventory
- A delivery mechanism
- Space to display the adverts
Inventory was going to be the hard one, we quickly settled on affiliate links for products that we thought would be useful or that we use ourselves here at NimbleWorks. A quick scoot round the services that we signed up to and ther were half a dozen affiliate links.
The delivery mechanism of choice for all of these ad networks is javascript and is fairly easy to implement. All you need is to deliver randomly an image, a link and small ammount of text.
function theAd(){
var adSpace = document.getElementById('adSpace');
var randNum=Math.floor(Math.random()*(ads.length));
var toInsert = '<a href="'+ads[randNum][1]+'"><img src="'+ads[randNum][0]+'"></a>
<span>'+ads[randNum][2]+'</span>';
adSpace.innerHTML = toInsert;
}
What we have here is an array of adverts, we select at random one of them and inset the HTML into a div with the id of "adSpace" on the page.
All in all 20 minutes work to put together. What took the most time was finding and collating the affiliate links and updating a few website to now display adverts.
Obviously what you don't get with this is any kind of statistics. Idealy the javascript code would request the advert from a webservice that tracks impressions and sites requesting it. All in all the process of delivering adverts is very simple, the hard bit is finding the advertising space and selling to the right companies. In the end the more highly targeted the advert the higher the posibility there is that a viewer will click and buy.