Archive for January 24th, 2007

HOWTO: find out who/what subscribes to your RSS Feed.

Today, while browsing my stats (provided via statcounter), I realized something interesting - I have no idea know who/what access my RSS feed.

Actually, if you think about it, most statistics software have no way of seeing who calls the RSS output (as they are javascript based).

So, I decided to see if I can write a simple script to write to a log file every time RSS is accessed.

Step 1: Script to write to a log file

[?php

$my_addy = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$my_uri = $HTTP_SERVER_VARS['REQUEST_URI'];
$my_browser = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
$my_ref = $HTTP_SERVER_VARS['HTTP_REFERER'];
$my_date = date(’Ymd’);
$my_filename = “/your server/stats/rss.log”;
$my_time = date(’h:i:s’);

$log_data_line = “#$my_ref|$my_date|$my_browser|$my_addy|$my_time|\n\n”;
$fp = fopen($my_filename, “a”);
fwrite($fp, $log_data_line);
fclose($fp);
?]

For the code to work:

  1. Paste it in a file with extension php, and upload that file to the base folder of your web site.
  2. You will need to change the first [ to an < and the last ] to an >
  3. Create a log file and replace /your server/stats/rss.log. Chmod that log file 666 (writeable)

Now, if you call this new script from the browser, it will dutyfully write a line to your new log file.

Step 2: Calling this process everytime someone requests your RSS/ATOM/whatever feed

(This process is for wordpress but you should be able apply the same concept to your blog/site software)

Edit the following files (wordpress): wp-rss2.php, wp-rss.php, wp-atom.php, wp-rdf.php and wp-commentsrss2.php, and write the following line at the top (after < ? php)

include 'yourscript.php';

where yourscript.php is the script that you made.

So, who/what accessed my RSS feed lately?

  1. Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)
  2. Akregator/1.2.5; librss/remnants
  3. Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061201 Firefox/2.0.0.1 (Ubuntu-feisty)
  4. msnbot/1.0 (+http://search.msn.com/msnbot.htm)
  5. Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
  6. Technoratibot/0.7
  7. Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
  8. Bloglines/3.1
  9. Blogslive (info@blogslive.com)
  10. Feedster Crawler/3.0; Feedster, Inc
  11. NewsGatorOnline/2.0
  12. http://www.relevantnoise.com; info@relevantnoise.com
  13. Mozilla/5.0 (compatible; Google Desktop)

NOTES

  • You can edit only wp-feeds.php and add the include to that script, but if someone/something directly subscribes to a specific output (e.g. atom) then they may not register, this is why I added the include to all the feed outputs
  • Yes there are some services which allow you to get stats for your scripts but you would have to generate the script via that service/web site which seems cumbersome - this method allows you to get the stats directly
  • The code can be improved, I know.
  • Another idea would be to output the log in a proper format that a statistics software would recognise so you can get nice graphs/stats/proper analysis

2 comments January 24th, 2007


Popular Posts

OMG! Ponies!

Most Recent Posts

Recent Comments

Categories

Feeds

Calendar

January 2007
M T W T F S S
« Dec   Feb »
1234567
891011121314
15161718192021
22232425262728
293031  

Posts by Month

Posts by Category

Links

Valid XHTML 1.0 Strict