diff --git chartbeat.module chartbeat.module
index 4025152..3b3e188 100644
--- chartbeat.module
+++ chartbeat.module
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function chartbeat_menu() {
   $items['admin/settings/chartbeat'] = array(
@@ -16,7 +16,7 @@ function chartbeat_menu() {
 }
 
 /**
- * Implementation of hook_perm().
+ * Implements hook_perm().
  */
 function chartbeat_perm() {
   return array(
@@ -25,12 +25,12 @@ function chartbeat_perm() {
 }
 
 /**
- * Implementation of hook_init().
+ * Implements hook_init().
  */
 function chartbeat_init() {
   $uid = variable_get('chartbeat_uid', '');
   if (is_numeric($uid)) {
-    drupal_set_html_head('<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>');
+    drupal_add_html_head('<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>');
     drupal_add_js(array('chartbeat' => array(
       'uid' => (int)$uid,
       'domain' => variable_get('chartbeat_domain', ''),
@@ -39,12 +39,11 @@ function chartbeat_init() {
 }
 
 /**
- * Implementation of hook_footer().
+ * Implements hook_page_alter().
  */
-function chartbeat_footer() {
-  $uid = variable_get('chartbeat_uid', '');
-  if (is_numeric($uid)) {
-    $output = <<<EOT
+function chartbeat_page_alter(&$page){
+  if ($uid = variable_get('chartbeat_uid', '')) {
+    $page['page_bottom']['chartbeat'] = array('#markup' => <<<EOT
 <script type="text/javascript">
   var _sf_async_config=Drupal.settings.chartbeat;
   (function(){
@@ -63,7 +62,7 @@ function chartbeat_footer() {
        loadChartbeat : function() { oldonload(); loadChartbeat(); };
   })();
 </script>
-EOT;
-    return $output;
+EOT
+);
   }
 }
