I saw this site: http://www.dotcomunderground.com/blogs/2006/07/01/free-rapidshare-premium-account/ How do they do the: People come here looking for: thing? What code do they do to do that?
They probably get that from the HTTP referer header sent by browsers. For example, someone might search for something on Google and Google will lead them to that site, so the referer might come out as "http://www.google.com/search?hl=en&q=rapid+share&btnG=Google+Search" You can read more about the HTTP referer header here: http://en.wikipedia.org/wiki/Referrer
I think you're right on the money. Tracking the header information to get the keyword and counting the number of them and storing it in their database.