Saturday, April 15, 2006 

[Adsense Profit to Pay Student Loans] : Filtering Targeted Ads

void main()

Today, I woke up and checked my Adsense account. A whopping $2.50! It was great. However, I still haven’t marketed the site-- so I have no idea where the clicks came from. But I sure aint complaining :-)

I ran a bunch of tests to make sure the submission of posts worked for all kinds of inputs. It turns out there were a few problems that I hadn't considered before.

  • The PHP DOM API that I use to parse the XML that stores the user's post assumes that the input file is UTF-8 encoded (as per the XML specifications). However, I write the file using the default encoding and when I read the data back to parse it (ISO-8859-1 encoding) the dom parser function complains. The solution was a simple conversion function built in to PHP -- utf8_encode(). I call this function on the input data prior to writing to the file and the problem was solved.

  • Another DOM problem surfaced when I was testing inputs with another character-- the ampersand. It turns out that all XML parsers treat single ampersands as special characters. The parser choked whenever it encountered one, so I had to figure out how to get around it. The solution was to incorporate another character replacement entry in the same function I use to strip PHP slashes and kill left brackets (to avoid bad html).

  • The default cut-off length for the input was too small. At first I thought 800 characters was plenty. However, it would be trivial to increase this amount, and some people like to write paragraphs or post poems on their posts. So I increased the maximum post size to 1500 characters to account for it.

Later on in the day, I was checking out the search page. Adsense was showing a bunch of horoscope ads, which I don't think pays as much as dating ads. Plus, I would want to keep the ads as consistent as possible-- most of the other pages show dating ads. I remembered seeing something about filtering when I was configuring my Adsense account, so I logged back in to see if I could do anything about the problem. I saw a section about a "competitive ad filter" and figured I'd check it out. Apparently, you can select which domains to prevent from showing ads on your site.

Great! So I went back to UpHook and grabbed the domain names of these horoscope sites. Then I put them in the filter and refreshed the search page. I didn't see any change-- but I guess it would probably take a while to have an effect. Either way, I realized just how powerful this could be. By restricting certain domains, you can probably force Adsense to display the next-best match for ads. In my case, this would be the dating and personals ads. I feel like this is just another small detail that could make a decent impact in Adsense revenue. After all, it's the little things that matter.