GIDNetwork > Fetching Unique Ads for a Contextual Advertising System
Register
« Still working on the BBCodes II... Beginning Python Tutorial (Part 10) »

Fetching Unique Ads for a Contextual Advertising System

by: admin - Mar 07, 2007

How does AdSense, or any other Contextual Advertising Network, fill their ad units with unique advertisements? This is a question I have been regularly asking myself the last couple of days.

A couple of days ago, I woke up with this urge to create my own "contextual advertising" thingy for my network of sites.

I have some experience writing similar PHP scripts before. One I wrote using database feeds off Per Pay Click Search Engines like Miva, Searchfeed, and a few others not worth mentioning.

I also wrote one specifically for GIDForums, where I had the script matching affiliate advertising for entire forum categories. For instance, I would submit a web hosting affiliate program (e.g. from Clickbank) to the MySQL database and have it displayed on all the forum pages under the Web Hosting Forums category. This one worked out rather well actually!

Fast forward to 2 days ago, I decided to write something better to replace these existing scripts. This new "contextual advertising" PHP script should allow me to target down to each individual web page if I wanted it to. That is the objective. However, that's not really a problem at the moment.

I have to figure out how to efficiently fetch unique advertisements off the database, for any given web page - and to make matters just a little more complicated, the advertisements would have to be sorted by bids -- just like AdSense!

Some other questions I asked myself recently:

  1. Why can I only insert a maximum of 3 AdSense ad units per web page?

  2. How does the AdSense javascript know which ads are already showing in a previous ad location on a web page?

Believe it or not, asking these questions in my head repeatedly helped me figure out one possible way for me to do it.

A 160x600 ad unit (the largest ad unit offered in the AdSense programme) displays up to 5 text advertisements at a time. Assuming there are 3 of these on a web page, my script would have to fetch a maximum of 15 unique advertisements per web page. Correct? I think so...

The Solution... probably

My advertising script could fetch the advertisements like this:

  1. Get the IP of the user, and the referring web page's URL.

  2. Look for a "cache" of advertisements matching this IP and URL created in the last 5 minutes.

    1. If one exists, get the required number of ads off the top (i.e. up to 5 maximum), deleting them off this "cache" at the same time.

    2. If it doesn't exist, fetch up to 15 advertisements off the database sorted by bids and store them to the "cache". Go back to step 2.a.

Simple, huh? and I think it does exactly what I want it to do.

I still haven't decided what this "cache" is going to be. Is it going to be a text file or will it just be another database table?

If you have any alternative ideas and suggestions, please write to me or leave a comment. I will appreciate it.

Would you like to comment? This story has been viewed 13,234 times.
« Still working on the BBCodes II... Beginning Python Tutorial (Part 10) »

__top__

Copyright © GIDNetwork™ 2001 - 2024

Another website by J de Silva

Page generated in : 0.01001 sec.