HOWTO: find out who/what subscribes to your RSS Feed.
January 24th, 2007
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:
- Paste it in a file with extension php, and upload that file to the base folder of your web site.
- You will need to change the first [ to an < and the last ] to an >
- 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?
- Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)
- Akregator/1.2.5; librss/remnants
- Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061201 Firefox/2.0.0.1 (Ubuntu-feisty)
- msnbot/1.0 (+http://search.msn.com/msnbot.htm)
- Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
- Technoratibot/0.7
- Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
- Bloglines/3.1
- Blogslive (info@blogslive.com)
- Feedster Crawler/3.0; Feedster, Inc
- NewsGatorOnline/2.0
- http://www.relevantnoise.com; info@relevantnoise.com
- 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
Entry Filed under: Misc
2 Comments Add your own
1. Ian Delaney | January 26th, 2007 at 3:11 pm
Delighted to have found your blog. So digg does work, after all!
Doubly pleased to find this post. Surely this should be an option at the very least in the 2.2 branch.
Cheers, Ian
2. n# | January 26th, 2007 at 11:36 pm
Thanks for the kind words
Leave a Comment
Trackback this post | Subscribe to the comments via RSS Feed