I run ads here. I know some people hate advertising, but the money has to come from somewhere. Writing articles and maintaining pages takes a significant amount of time, so advertising is a necessity.
But running the ads has become complicated. As the site has grown, I have more choices of ads to run. There's Google, YPN, Chitika, and I have direct ads too: ads that individual companies have paid for.
There are rules.
Google won't let you run certain types of ads more than once per page. Google won't let you run any other contextual ads on the same page as theirs, or any ads that just look like their ads. Google doesn't let you run ads on certain kinds of pages (search results, newsgroup postings). YPN has similar rules, and so does everyone else. Because I generate ads dynamically rather than hard-coding them into the page, I ended up with a very complicated piece of code to avoid breaking any rules.
There's another problem. I both need and want to control ratios. For example, I might want to give YPN 25% of the pages, but always give page xyz to direct adveriser z. That gets very complicated.
It's time for a rewrite. I've been thinking about how to handle all this, and thought that the easiest way is probably a little database that specifies what ads a page can run. That translates into a fair amount of storage just because of the sheer volume of pages here, and I'd like to avoid that for performance reasons, so my next thought was to generate a hash of the page URL and pick the ad type from that. But then that means that page X always gets ad type X, and that's not good. So I had a better idea: hash the URL, but then look that hash up in a small database that has the ad type to run. That little database can be randomly changed on a daily basis, allowing me to control ratios of ads types to run easily.
So, yet another project. Good thing I don't sleep much.
Got something to add? Send me email.
More Articles by Anthony Lawrence © 2009-11-07 Anthony Lawrence
We are questioning more than the philosophy behind our dependence upon limited and limiting systems. We question the power structures that have grown up around such systems (Frank Herbert).