Rogue Wolves is the personal site of .

I'm currently a research scientist with Oculus Info Inc. in Toronto, Ontario Canada.

My research interests include: adaptive user interfaces, machine learning, Bayesian reasoning and distributed artificial intelligence.

Drupal and FeedBurner

I recently decided to play around with FeedBurner and get some useful stats on my RSS feed. If you ever wanted to know how many people subscribe to your feed, what they use, and track hits then you should check out FeedBurner. Plus it's free! (you can pay for a pro account that gives you even more ways of slicing and dicing your stats)

Instructions for integrating FeedBurner into Drupal

In order to use FeedBurner you need to tell FeedBurner where your RSS feed exists and then you need to direct all of your site visitors to subscribe not to your Drupal feed but rather to the feed that FeedBurner will create for you. This way all your feed traffic will pass through FeedBurner so they can calculate all those fancy stats.

There are several ways to integrate this. Here are a few:

  1. You could setup FeedBurner to point directly to your Drupal feed and then modify your site theme so that the RSS links point to the FeedBurner RSS url. Plus you'd also want to modify the RSS url for autodiscovery (the feature that lets your browser or feed reader detect that an RSS feed is present on the current webpage). To change the autodiscovery feature you can follow this thread on Now when someone subscribes to your site they will use your FeedBurner RSS feed so you can track stats.
  2. The above option has a big problem. Those subscribers that have already subscribed to your RSS feed will still be grabbing your feed from Drupal rather than from FeedBurner. So all your current subscribers will be ignored in the FeedBurner stats. Blah. To get around this you can modify your .htaccess file and redirect your traffic to your drupal rss feed to the feedburner rss feed! Aha! It's fixed! Um, not quite... If you do this you will break FeedBurner because it also uses your drupal rss feed! So you'd be redirecting feed burner back to itself! Frustrated yet? So in order for this to work you need Feedburner to have a special "hidden" url to get to your RSS feed (that doesn't get redirected). This allows FeedBurner to get to your drupal feed and subscribers to your Drupal feed to get redirected to the FeedBurner feed. Then you could do the other hacks in option 1 to make sure new subscribers use your FeedBurner feed too.
  3. You SMRT people out there may have picked up on something. Why do we need to do all that stuff in Option 1 if we are already redirecting our Drupal feed url to FeedBurner? Good call! Simple answer? You don't! So this option is the simplified way to integrate FeedBurner. It involves creating a special "hidden" url so FeedBurner can get to your Drupal RSS feed and some rewrite rules in your .htaccess file to redirect all traffic to your drupal feed to your FeedBurner feed. That's it! This will take care of new subscribers to your feed and current subscribers with minimal fuss. This option also lets you have control over your feed since all feed requests goes through your site.

More details inside...

So how do we implement Option 3?

Here's a breakdown of how to create that special "hidden" url for FeedBurner. In Drupal you can create aliases for URLs, which is just another URL that points to something. This is done in the Administration/url aliases menu.

Adding a URL alias in Drupal

The above image shows me creating a url alias for rss.xml which is the system path for the main Drupal RSS feed. I'm creating an alias for this with a name of fbfeed. So now I can access my Drupal feed using the alias path fbfeed. In FeedBurner when you are specifying the URL of your original feed you'd type:

Note: Obviously you need to substitute with your actual domain name.

Now FeedBurner knows where your feed is using a special alias to it that won't be redirected. The next step is to redirect all traffic to your Drupal feed to your Feed Burner feed.

To do this you need to modify the .htaccess file in your Drupal site directory. We are going to add some instructions for our webserver to redirect traffic. Here are two ways to do this:

  1. Redirect all traffic for your drupal feed to Feed Burner feed. Insert these lines in your .htaccess file, substituting your Drupal feed URL and FeedBurner URL. Redirect temp Redirect temp
  2. Use mod rewrite to redirect your Drupal feed to the Feed Burner feed. This can be handy if you have multiple domains running on the same code. RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule rss.xml http://feeds\.feedburner\.com/YourHost [R,L] RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule node/feed http://feeds\.feedburner\.com/YourHost [R,L] Note the [R,L] at the end of the RewriteRule. This tells mod rewrite to do a temporary redirect (302 response) and to stop processing rewrite rules.

Note: A temporary redirect (302) instructs clients that the requested resource temporarily resides at a different URI but since it's only temporary the client should continue to use this URI to connect to the resource.

What are the benefits of using temporary redirects rather than using permanent redirects or modifying your templates to point directly to Feed Burner? You don't hand over the keys to your RSS feeds to FeedBurner. Instead you are just lending them the keys for a while. Subscribers are being piped through your system to FeedBurner and not the other way around. If you ever decide not to use FeedBurner anymore...just remove the redirect and your site will serve up your RSS like normal. Or maybe another service that is better than FeedBurner comes along. All you need to do is manipulate your redirect rules and voila! All your subscribers will be updated without them having to do a thing.

On Last Note: I think these instructions will only work with clean urls turned on. You'd need to modify the URLs a bit.