(last updated on April 29, 2014)
I set up a Feedburner account to try to track this site’s syndication activity. Feedburner repackages your syndication feeds so that’s possible, since a feed is not an actual web page viewed in a browser. If they were, you could track them through your web logs or a service like StatCounter. Up to now, I had no idea how many people were visiting this site through RSS readers (such as Firefox’s Live Bookmarks) or through an agregator like Bloglines.
Geeky notes follow on how I implemented this, so I don’t forget.
Just so you know, you theoretically don’t need to use a service like StatCounter or Feedburner to get site statistics if you already have access to your web server logs. However, extracting the information from server logs is a tedious affair compared to visiting a spiffy service provider that makes all that data pretty to look at. These services also do additional processing to weed out duplicate data. It’s totally worth it.
The Game Plan
The tricky part is that I already had the default WordPress system feed in service, and I knew that people had subscribed to it. The last thing I wanted to do was send an email out telling everyone to switch over, and I’m not sure how to even tell RSS aggregators like Bloglines to update (maybe a redirect is a feature of RSS, but I didn’t know).
So I did the switcheroo as described in the Feedburner forums:
- Create a separate feed URL just for Feedburner
- Point Feedburner to the new, separate feed URL
- Redirect your old feed URL to Feedburner, so current subscribers are happy
Doing this is a little involved (hence these notes), so you might consider using that nice Feedburner WordPress Plugin that does all this for you. If you have a tweaked version of your
.htaccess file, you may have to do everything manually (which is the only reason I’m not using it).
Be Warned! There is the real possibility of screwing up your website! Not permanently, but you will probably have to recreate your
.htaccessfile via the WordPress admin panel.
If that happens, go to Options->Permalinks, scroll to the bottom of the page, and you’ll see what your
.htaccess file should look like, assuming there was nothing else special about it…
1. Setting Up The New Feed URL
The first step is to create that private Feedburner URL (step 1). Only Feedburner uses this URL; it’s the source RSS that FB will redistribute and track.
I create the private Feedburner URL by duplicating the existing
mod_rewrite rule for the WordPress feed, located in the almighty
.htaccess file. The following line:
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
…becomes two lines; the second line has been changed from “feed” to “feedburner”:
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L] RewriteRule ^feedburner/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
[note] These RewriteRule lines are a single line, but wrap when displayed in this article format. So pretend everything is just on one line everwhere you see RewriteRule…[/note]
So the new private URL, for use only by Feedburner is:
You’ll “burn” this URL in step 2. Note that we haven’t updated the OLD feed URL yet…that happens in step 3.
2. Setting Up Feedburner
Ok, go to feedburner.com and get a new feed URL. This is the one we want everyone to use, because Feedburner will be tracking hits to it. Mine looks like:
Then I specified what feed to burn…it’s the new FeedURL from the previous step:
You’re done with Feedburner setup, so on to Step 3!
3. Redirecting the Old Feed to Feedburner
Now, to point the old FeedURL to the new, we just modify the existing rewrite rules. It’s back to the
.htaccess file! There are two lines that need modification in my file:
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L] RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /index.php?&feed=$1 [QSA,L]
…are edited to point to FeedBurner, instead of the WordPress Feed PHP:
RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/DavidSeah-BetterLivingThroughNewMedia [QSA,L] RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ http://feeds.feedburner.com/DavidSeah-BetterLivingThroughNewMedia [QSA,L]
And that pretty much seems to do the trick.
Test your feed URL on your website (it should look all different now, if it’s properly coming from Feedburner.com). Test bloglines. Test Live Bookmarks. Check your HTML code for the meta tags that define your syndication feeds. Sometimes it takes a while for the agregators to catch on to the change, so wait a while before checking. You might have to flush your browser cache also, if you are checking the RSS link manually.
If you are using a caching plugin for WordPress, you may have to add the new
/feedburner URL to the do not cache list. This bit me on the ass a couple of times.
Note 1: I’m not very familiar with mod-rewrite, but I did have to change the top rule that looks like this where it says 49, because this is the number of lines (I think) that the rewrite condition works with. If you don’t increment the number, the very last rewrite condition won’t be used, which will break your site in a subtle fashion. The line looks something like this, and is at the very top:
RewriteRule ^.*$ – [S=49]
Note 2: You could also theoretically modify your WordPress installation if you know PHP, but it would be a significant amount of work that Feedburner has already done. And besides, I like to run my WordPress installation as vanilla as possible to make security updates easier. It would be nice if future versions of WordPress provided the option for “hosted RSS feeds”as the current code embeds meta tags in your HTML that point to the default WordPress RSS feed URL. Even better, it would be nice to get a hook to the RSS reading…I wonder if you could snag the referrer from one of
the_rss action or something similar and build it into a plugin…but there’s still a lot of annoying data collection and management you’d have to do.