FeedBurner CFC

I've been using FeedBurner for quite sometime now to host my RSS feeds, and when they bought Blogbeat, I was even happier since Blogbeat was a great blog-stats tool. Now I get both feed and general item stats all from one source. FeedBurner has an API to retrieve information about your stats so I decided to wrap up some of the API into a nice little CFC. FeedBurner.cfc supports getting both general feed data as well as item data. For example:

<cfset fb = createObject("component", "feedburner")> <cfdump var="#fb.getFeedData('RaymondCamdensColdFusionBlog')#" label="No date, will be yesterday">

This will retrieve the most current stats from the API, which will be yesterday. To get a week of data:

<cfset date = dateAdd("d", -8, now())> <cfset last7 = fb.getFeedData(uri='RaymondCamdensColdFusionBlog',dateBegin=date)> <cfdump var="#last7#" label="7 Days of Info">

And finally last month:

<cfset date = dateAdd("m", -1, now())> <cfset dateBegin = createDate(year(date), month(date), 1)> <cfset dateEnd = createDate(year(date), month(date), daysInMonth(date))>

<cfset lastm = fb.getFeedData(uri='RaymondCamdensColdFusionBlog',dateBegin=dateBegin,dateEnd=dateEnd)> <cfdump var="#lastm#" label="Last Month">

This data then can easily be dumped into a chart:

Here is a live demo.

Along with general feed stats you can get information about individual URLs and their stats over time:

<cfdump var="#fb.getItemData('RaymondCamdensColdFusionBlog')#" label="No date, will be yesterday">

<cfset date = dateAdd("d", -8, now())> <cfset last7 = fb.getItemData(uri='RaymondCamdensColdFusionBlog',dateBegin=date)>

<cfquery name="getTop" dbtype="query"> select sum(clickthroughs) as ctsum, sum(itemviews) as itsum, downloads, title, url from last7 group by url, title, downloads order by itsum desc, ctsum desc </cfquery>

<cfdump var="#getTop#" top="100">

This code shows first getting data from yesterday and getting last week. I then do a query of query so I can find my top entries. If you want to see a live dump of this, please visit this demo.

The CFC, along with sample code, is attached below. A warning first though before you download - and a funny story. FeedBurner gives you nice control over the dates you can retrieve when fetching data. On a whim I was testing a date range of today to 1900. Yes, 1900. And the API worked. Well, technically it worked too well - I couldn't get it to retrieve as it took to long. I then switched to 1990 and yep - it fed me stats.

Now for the fun part - apparently my site had a few downloads in 1990. Back when I was a Junior in high school (and I was the coolest kid at my high school, seriously). I'm assuming this is a bug... but it's certainly an odd bug.

Another bug is that my item stats for yesterday appear to be randomly returning no records at times. If I had to guess, I'd say they have a cluster and one machine is fetching old data.

Anyway - I've posted to their forums on both issues. Let me know if you find this useful.

Download attached file.

Archived Comments

Comment 1 by Chris Peters posted on 1/30/2008 at 8:58 PM

I just did a Google search for "coldfusion feedburner," and it never fails that you show up on these kinds of searches, Ray. :)

I'm looking into building some really killer dashboards and apps for a marketing system, and I could see this being immensely useful. I'm getting tired of logging into different systems to get to my data, so I'm appreciative of finding this CFC as a first step in some major integration!

Comment 2 by Raymond Camden posted on 1/30/2008 at 9:04 PM

Glad you like it. I don't think many people used it.

Comment 3 by Chris Peters posted on 1/30/2008 at 9:10 PM

It's ridiculous that few business use these great APIs to get to the data that really matters. I would say that CF developers seem to be behind in this, but then I realize that it's not unique to CF.

Again, your curiosity and willingness to tinker is much appreciated!