For a while now, I was interested in knowing how many actual subscribers I had to my blog. While my Blog stats showed me general stats, it did not show me a count of the RSS subscribers. Luckily, Peter had the same idea and wrote some handy code which I used as a basis for my tracking.
I added in a few extra fields so capture the user_agent and remote_host fields aswell as the last date the feed was consumed.
I reckoned Peters way was fairly clever and was simple to implement.
The basis is to use CFHEADER to send a message of Moved Permanently so the users agent would update their feed which infact tacked on a UID to identify them.
By checking to see if the UID was present on subsequent calls, I could update the other fields.
Below is a shot of the code and it is short and should make alot of sense.
I also have a field in the database which marks whether the subscriber is an aggregator or an RSS Reader. I am going to use this to place badges on my blog showing the number of individual subscribers like FeedBurner
If nothing else, this little excerise has thought me to look into the ON DUPLICATE KEY UPDATE directive in SQL and the ability to chain a number of updates together.