Simple unobtrusive site stats with Feedburner or Google Analytics 1

Posted by Tim Connor Mon, 23 Apr 2007 01:07:00 GMT

Neither Analytics or Feedburner have directions for attaching their scripts “properly:” in the head element and without in-lined javascript. Yet both of them work fine, when you do.

For feedburner, just follow the directions for the simplestats, but put the script tag in the head, not in the body, as directed:

<head>
  <script src="http://feeds.feedburner.com/~s/yourusername.js" type="text/javascript"></script>
</head>
For Analytics, attach the script, and use some method of calling a cross-browser DOMContentLoaded. I, use the one from lowpro since I’m mainly developing in Rails, so using Prototype is a no-brainer.

<head>
  <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
  <script type="text/javascript">
    _uacct = 'UA-yoururchinaccountcode-1';
    Event.onReady(urchinTracker);  
  </script>
</head>
  1. the1confusion@hotmail.com about 1 year later:

    I think the reason why google asks you to put the javascript just before your is that in the event of google’s server being unreachable poeople will still see your sites contents.

    When the script is in the head it needs to be fully loaded before the sites content is diplayed.

Comment form

(leave url/email »)

Help with Textile (code)