cftopper.com

Tracking RSS Feeds

I was thinking that I'd love to have some sort of idea how many people are subscribed to this site.

The Solution

Solution 1: Some people suggest using a HTTP 301 Moved Permanently header to redirect RSS Readers to a unique URL that you can use to track the feed.

Solution 2: Others recommend that you display/make-available a unique RSS feed URL every time you display your blog.

The Problem

The problem with solution 1 is that RSS readers *should* remember that the page is permanently redirected - if they don't you'll get users always being redirected to unique URLs looking like unique subscribers all-the-time.

The problem with solution 2 is that it doesn't track your existing subscribers.

What I Decided to Do

I decided to combine both solutions and hope that there aren't too many stupid RSS readers out there. Now, If you browse to to rss/ you will be redirected to a unique URL.

Also when you view this page, both the RSS feed in the header and the feed displayed on the right hand side are unique.

The Code (in Brief)

For the redirect if URL.ref isn't defined, I used:

<CFHEADER statuscode="301" statustext="Moved Permanently">
<CFHEADER name="Location" value="#UniqueRSSURL#">

For the unique Id in the RSS URL I simply used:

replace(CreateUUID(),"-","","ALL"Wink

For logging to the MySQL RSSHits table I used:

<cfquery name="updateBlogHitCounter" ...>
INSERT INTO RSSHits(ref,blogId,hits)
VALUES (<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#ref#">,
<cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#URL.blogId#">,1)
ON DUPLICATE KEY UPDATE hits = hits + 1;
</cfquery>
Tags: ColdFusion | Tips

About Topper on ColdFusion

Peter Coppinger aka Topper is a neurotic web monster who spends most of his chaotic life developing ColdFusion web applications when not drinking himself into a stupor and scheming his plans for world dominance.

Peter founded Digital Crew way back in 1999. Digital Crew run CFTagStore.com and have also produced lots of powerful ColdFusion tools like ProFlashUpload and CFMyAdmin.

I made this site to share my thoughts, tips and tools with fellow ColdFusion developers.

If your a ColdFusion developer, go ahead and subscribe to this site and in exchange i'll try to provide quality content to make it worth your while.
RSS Feed for Topper on ColdFusion

    I'm speaking at CF-United Europe!

    CFDevCon I'm going to be speaking at CFDevCon08! It's my second time speaking in front of more than 10 people so please lend your support.

    The topic is:
    Introducting TeamworkCMS and Site Engine - Building better websites in half the time or something like that..

    Digging

    My Work - Just Finished

    • modules.cit.ie
      Web-=based modules/programmes designer tool and database system for Cork institute of technology.
    • Teamwork Project Manager
      The top secret project is finally released. The project management app will rock your world - give it a go.
    • PMG
      New website for Project Management Group website.
    • Digital Warehouse Wholesale
      Added wholesale products to existing client website.
    • New Digital Crew documentation website
      New version of documentation.digital-crew.com using new InfinityCMS site engine. It's done now. Just add content.
    • PFH Company Webite
      New website/CMS/Newsletter System for prestigious Irish IT company.
    • Module Manager for CIT
      CIT is switching to module based courses. We are making an application for managing/submitting these modules. Gettig there.
    • Bons Secours Cork Hospital Intranet
      New Intranet for Bons Secours hospital in Cork. Considering turning this Intranet system into stand-alone product.
    • Revamping InfinityCMS
      I'm making major improvements to our content management solution, InfinityCMS. Making it faster, more powerful and easier to check into/out-of source control. Done but it's always going to be evolving.
    • BPC Update
      Minor functionality update for internal Pfizer Best Process Chemistry project.