diff --git woopra.info woopra.info
index 31832d7..1be0dcf 100644
--- woopra.info
+++ woopra.info
@@ -2,4 +2,7 @@
 name = Woopra
 description = Adds support for the Woopra web analytics system
 package = Other
-core = 6.x
+core = 7.x
+
+files[] = woopra.install
+files[] = woopra.module
diff --git woopra.install woopra.install
index b51961a..9098812 100644
--- woopra.install
+++ woopra.install
@@ -1,6 +1,19 @@
 <?php
+/**
+ * @file
+ * Install, update and uninstall functions for the woopra module.
+ *
+ */
  // $iD: woopra.install,v 1.1 2008/04/21 15:04:08 tomdeb Exp $
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function woopra_uninstall() {
-  db_query('DELETE FROM {variable} WHERE name LIKE "woopra\_%"');
+  // TODO Please review the conversion of this statement to the D7 database API syntax.
+  /* db_query('DELETE FROM {variable} WHERE name LIKE "woopra\_%"') */
+  db_delete('variable')
+  ->condition('name', "woopra\_%", 'LIKE')
+  ->execute();
 }
diff --git woopra.module woopra.module
index 8d739f8..10f6daa 100644
--- woopra.module
+++ woopra.module
@@ -10,22 +10,22 @@
  */
 
 /**
- * Implementation of hook_help
+ * Implements hook_help().
  */
 function woopra_help($path, $arg) {
   switch ($path) {
-    case 'admin/settings/woopra':
+    case 'admin/config/system/woopra':
       return t('Woopra is a realtime tracking and statistics system.');
   }
 }
 
 /**
- * Implementation of hook_menu
+ * Implements hook_menu().
  */
 function woopra_menu($may_cache = TRUE) {
   $items = array();
   if ($may_cache) {
-    $items['admin/settings/woopra'] = array(
+    $items['admin/config/system/woopra'] = array(
       'title' => t('Woopra'),
       'description' => t('Change Woopra integration settings'),
       'page callback' => 'drupal_get_form',
@@ -39,35 +39,40 @@ function woopra_menu($may_cache = TRUE) {
 /**
  * admin/settings/woopra form
  */
-function woopra_settings_form() {
+function woopra_settings_form($form, &$form_state) {
 
   $form['info'] = array(
     '#type' => 'fieldset',
     '#title' => t('User Information'),
-    '#description' => t('Woopra can display all sorts of information for real-time tracking of users.'), 
+    '#description' => t('Woopra can display all sorts of information for real-time tracking of users.'),
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
   );
+  $form['info']['woopra_domain'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Domain'),
+    '#default_value' => variable_get('woopra_domain', ''),
+  );
   $form['info']['woopra_email'] = array(
     '#type' => 'checkbox',
     '#title' => t('Email address'),
     '#default_value' => variable_get('woopra_email', FALSE),
-  ); 
+  );
   $form['info']['woopra_avatar'] = array(
     '#type' => 'checkbox',
     '#title' => t('Avatar'),
     '#default_value' => variable_get('woopra_avatar', FALSE),
-  ); 
+  );
 
   if (module_exists('profile')) {
     foreach (profile_categories() as $category) {
       $fields = _profile_get_fields($category['name']);
       while ($field = db_fetch_object($fields)) {
-        $form['info']['woopra_'. $field->name] = array(
+        $form['info']['woopra_' . $field->name] = array(
           '#type' => 'checkbox',
           '#title' => $field->title,
-          '#default_value' => variable_get('woopra_'. $field->name, FALSE),
-         ); 
+          '#default_value' => variable_get('woopra_' . $field->name, FALSE),
+        );
       }
     }
   }
@@ -79,21 +84,21 @@ function woopra_settings_form() {
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
   );
-  
-  $admin = user_load(array('uid' => '1'));
-  
+
+  $admin = user_load('1');
+
   $form['roles']['woopra_track_user1'] = array(
     '#type' => 'checkbox',
     '#title' => t("%admin (user #1)", array('%admin' => $admin->name)),
     '#default_value' => variable_get('woopra_track_user1', FALSE),
-  ); 
-  
+  );
+
   $roles = user_roles();
   foreach (array_keys($roles) as $rid) {
-    $form['roles']['woopra_track_rid_'. $rid] = array(
+    $form['roles']['woopra_track_rid_' . $rid] = array(
       '#type' => 'checkbox',
       '#title' => $roles[$rid],
-      '#default_value' => variable_get('woopra_track_rid_'. $rid, TRUE),
+      '#default_value' => variable_get('woopra_track_rid_' . $rid, TRUE),
     );
   }
 
@@ -101,54 +106,66 @@ function woopra_settings_form() {
 }
 
 /**
- * Implementation of hook_footer
+ * Implements hook_page_alter().
  */
-function woopra_footer($main = 0) {
+function woopra_page_alter(&$page) {
   global $user;
-  global $base_url;
-  $script = '';
+  
+  
   if (arg(0) != 'admin') {
-    if ((_woopra_track($user))) {
-      $woopra_js = '//static.woopra.com/js/woopra.v2.js';
-      $script .= "<script type=\"text/javascript\" src=\"$woopra_js\"></script>\n";
-      $script .= "<script type=\"text/javascript\">\n  woopraTracker.track();\n</script>\n";
+    if (_woopra_track($user)) {
+      extract(parse_url(url('', array('absolute' => TRUE))));
+
+      $settings = array();
+      
+      if ($domain = variable_get('woopra_domain', NULL)) {
+        $settings['woo_settings']['domain'] = $domain;
+      }
+      
+      $settings['woo_visitor'] = _woopra_user(user_load($user->uid));
+
+      $script = '';
+      foreach ($settings as $key => $setting) {
+        $script .= 'var ' . $key . ' = ' . drupal_json_encode($setting) . ";\n";
+      }
+      drupal_add_js($script, array('type' => 'inline', 'scope' => 'footer'));
+
+      $woopra_js = $scheme . '://static.woopra.com/js/woopra.js';
+      drupal_add_js($woopra_js, array('type' => 'external', 'scope' => 'footer'));
     }
   }
-  return $script;
 }
 
 /**
- * Build the user tracking variable 
- * @param $user
+ * Build the user tracking variable
+ * @param $account
  *   The user object
  * @return string
  *   The javascript string for this user
  */
-function _woopra_user($user) {
-  $script = "var woopra_array = new Array();\n";
-  $script .= "woopra_array['name'] = '$user->name';\n";
+function _woopra_user($account) {
+  $settings = array();
+  $settings['name'] = $account->name;
 
   // email support
   if (variable_get('woopra_email', FALSE)) {
-    $script .= "woopra_array['Email'] = '$user->mail';\n";
+    $settings['email'] = $account->mail;
   }
   // avatar support
-  if ((variable_get('user_pictures', FALSE)) && ($user->picture)) {
-    global $base_url;
-    $script .= "woopra_array['avatar'] = '$base_url/$user->picture';\n";
+  if ((variable_get('user_pictures', FALSE)) && ($account->picture)) {
+    $settings['avatar'] = (module_exists('image') && variable_get('user_picture_style', FALSE) ? image_style_url(variable_get('user_picture_style', 'default'), $account->picture->uri) : file_create_url($account->picture->uri));
   }
   // profile fields support
-  if (module_exists('profile')) {
+  /*if (module_exists('profile')) {
     profile_load_profile($user);
     $fields = db_query('SELECT * FROM {profile_fields}');
     while ($field = db_fetch_array($fields)) {
-      if (variable_get('woopra_'. $field['name'], FALSE)) { 
-        $script .= "woopra_array['". $field['title'] ."'] = '". $user->$field['name'] ."';\n";
+      if (variable_get('woopra_' . $field['name'], FALSE)) {
+        $script .= "woopra_array['" . $field['title'] . "'] = '" . $user->$field['name'] . "';\n";
       }
     }
-  }
-
-  return $script;
+  }*/
+  return $settings;
 }
 
 /**
@@ -158,16 +175,16 @@ function _woopra_user($user) {
  * @return boolean
  *   TRUE if page should be tracked, FALSE if not
  */
-function _woopra_track($user) {
-  $track = TRUE; 
+function _woopra_track($account) {
+  $track = TRUE;
 
-  foreach (array_keys($user->roles) as $rid) {
-    if (!variable_get('woopra_track_rid_'. $rid, TRUE)) {
+  foreach (array_keys($account->roles) as $rid) {
+    if (!variable_get('woopra_track_rid_' . $rid, TRUE)) {
       $track = FALSE;
     }
   }
-  
-  if ($user->uid == '1') {
+
+  if ($account->uid == '1') {
     $track = variable_get('woopra_track_user1', FALSE);
   }
 
