Warning: Table './schoonz_drupal7/watchdog' is marked as crashed and last (automatic?) repair failed query: INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '%message in %file on line %line.', 'a:4:{s:6:\"%error\";N;s:8:\"%message\";s:30:\"Function split() is deprecated\";s:5:\"%file\";s:63:\"/home/schoonz/public_html/sites/all/themes/zen/zen/template.php\";s:5:\"%line\";i:132;}', 3, '', 'http://www.schoonzie.com/how-setup-feedburner-stats-drupal', '', '54.89.68.105', 1413952970) in /home/schoonz/public_html/includes/database.mysql.inc on line 128
How to setup FeedBurner Stats on Drupal | Schoonzie

How to setup FeedBurner Stats on Drupal

24 comments
FeedBurnerI just setup FeedBurner Stats tracking code on this blog and had a few problems with the Drupal code that FeedBurner supplies. The main problem is that it doesn't get the proper page URL when put into a block.

Putting javascript tracking codes in blocks has a number of benefits, the main ones being that you can use the block visibility settings to show it only for specific user roles (eg - not site administrators).

The code that Feedburner provide is:

<script src="http://feeds.feedburner.com/~s/yourfeedburnername?i=http://yoursite.com<?php print $node_url ?>" type="text/javascript" charset="utf-8"></script>

This code will work properly if placed in the Node.tpl.php file in your theme directory - which isn't a great option because

  1. It's hard to limit the roles that are tracked and
  2. It will only show on node pages and not any other system pages or views
  3. Not everyone has access to the theme files and wants to mess around with them

Here is the modified code that will work when placed in a block.

<script src="http://feeds.feedburner.com/~s/yourfeedburnername?i=http://www.yoursite.com/<?php print $_REQUEST['q'] ?>" type="text/javascript" charset="utf-8"></script>

The code is by no means perfect but it does the job. If you are not using clean URLs (who isn't these days) you may want to add ?q= after yoursite.com/ otherwise the URLs in FeedBurner Stats won't match up correctly to the URLs on your site.