diff --git a/mixpanel.api.inc b/mixpanel.api.inc
deleted file mode 100644
index 952ccc4..0000000
--- a/mixpanel.api.inc
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php 
-
-/**
- * If you wish to do metric logging from your backend, the best method of doing this is
- * to do it in a non-blocking way. This will let your pages continue to execute at
- * about the same speed  while logging metric data in the background. Please note: If
- * you're on a shared host, you may be limited in logging metric data with a background
- * process.
- *
- * Feel free to modify this code to your own environments liking.
- *
- */
-class MetricsTracker {
-    public $token;
-    public $host = 'http://api.mixpanel.com/';
-    public function __construct($token_string) {
-        $this->token = $token_string;
-    }
-    function track($event, $properties=array()) {
-        $params = array(
-            'event' => $event,
-            'properties' => $properties
-            );
-
-        if (!isset($params['properties']['token'])){
-            $params['properties']['token'] = $this->token;
-        }
-        $url = $this->host . 'track/?data=' . base64_encode(json_encode($params));
-        // You still need to run as a background process.
-        exec("curl '" . $url . "' >/dev/null 2>&1 &");
-        // Uncomment the following line and comment the previous line to send events to /tmp/drupal_debug (devel module must be installed).
-        //dd($params);
-    }
-
-    function track_funnel($funnel, $step, $goal, $properties=array()) {
-        $properties['funnel'] = $funnel;
-        $properties['step'] = $step;
-        $properties['goal'] = $goal;
-        $this->track('mp_funnel', $properties);
-    }
-}
diff --git a/mixpanel.module b/mixpanel.module
index 75c3da6..dd44688 100644
--- a/mixpanel.module
+++ b/mixpanel.module
@@ -1,12 +1,11 @@
 <?php
 
-include('mixpanel.api.inc');
-
 include('includes/mixpanel.node.inc');
 include('includes/mixpanel.user.inc');
 include('includes/mixpanel.comment.inc');
 include('includes/mixpanel.og.inc');
 
+define('MIXPANEL_API_URL', 'http://api.mixpanel.com/');
 
 /**
  * Implementation of hook_init().
@@ -95,12 +94,23 @@ function mixpanel_requirements($phase) {
 }
 
 /**
+ * Implementation of hook_cron_queue_info().
+ */
+function mixpanel_cron_queue_info() {
+  return array(
+    'mixpanel_track' => array(
+      'worker callback' => '_mixpanel_track_queue_callback',
+    ),
+  );
+}
+
+/**
  * Setup default variables for Mixpanel to send.
  *
  * @return array of the default mixpanel variables.
  **/
 function mixpanel_get_defaults($account = NULL, $reset = FALSE) {
-  static $defaults;
+  static $defaults = array();
 
   // If user object is passed in, favor that, otherwise, set $account = the current object.
   if($account == NULL) {
@@ -108,28 +118,29 @@ function mixpanel_get_defaults($account = NULL, $reset = FALSE) {
     $account = $user;
   }
 
-  if (!isset($defaults) || $reset) {
+  if (!isset($defaults[$account->uid]) || $reset) {
     $cohort = format_date($account->created, 'custom', "M-Y");
-    $defaults = array(
+    $defaults[$account->uid] = array(
       'uid' => $account->uid,
       'user_created' => $account->created,
       'cohort' => $cohort,
-      'mp_name_tag' => $user->name,
+      'mp_name_tag' => $account->name,
       'distinct_id' => $account->uid,
-      'ip' => $_SERVER['REMOTE_ADDR'],
+      'ip' => ip_address(),
     );
 
     // Let other modules alter the defaults.
-    drupal_alter('mixpanel_defaults', $defaults, $account);
+    drupal_alter('mixpanel_defaults', $defaults[$account->uid], $account);
   }
 
-  return $defaults;
+  return $defaults[$account->uid];
 }
 
 function mixpanel_track($event, $custom_properties = array(), $account = NULL) {
   global $user;
   
-  if (variable_get('mixpanel_token', '') == '') {
+  $token = variable_get('mixpanel_token', '');
+  if ($token == '') {
     return;
   }
 
@@ -147,15 +158,50 @@ function mixpanel_track($event, $custom_properties = array(), $account = NULL) {
   }
   
   // Let other modules alter the properties.
-  drupal_alter('mixpanel_event', $properties, $event);
-  
-//  dsm(array('event'=>$event, 'prop' => $properties));
-  $token = variable_get('mixpanel_token', '');
-  $metrics = new MetricsTracker($token);
-  $metrics->track($event, $properties);
+  drupal_alter('mixpanel_event', $properties, $event, $account);
+
+  // These properties can't be overridden
+  $properties['token'] = $token;
+  $properties['time'] = time();
+
+  if (module_exists('drupal_queue')) {
+    // if possible, we queue up the API call to actually be made on cron
+    $queue = drupal_queue_get('mixpanel_track');
+    $queue->createItem(array('event' => $event, 'properties' => $properties));
+  }
+  else {
+    // Actually send the request NOW.
+    _mixpanel_track($event, $properties);
+  }
 }
 
+function _mixpanel_track($event, $properties) {
+  $params = array(
+    'event' => $event,
+    'properties' => $properties,
+  );
+  $url = MIXPANEL_API_URL . 'track/?data=' . base64_encode(drupal_to_js($params));
+
+  $result = drupal_http_request($url);
+
+  if ($result->code != 200) {
+    watchdog('mixpanel', 'Unable send event %event to Mixpanel with properties: %properties', array('%event' => $event, '%properties' => drupal_to_js($properties), WATCHDOG_ERROR));
+    return FALSE;
+  }
 
+  return TRUE;
+}
+
+function _mixpanel_track_queue_callback($item) {
+  // actually send the request to the Mixpanel API
+  $success = _mixpanel_track($item['event'], $item['properties']);
+
+  // if it was unsuccessful, we re-queue the item
+  if (!$success) {
+    $queue = drupal_queue_get('mixpanel_track');
+    $queue->createItem($item);
+  }
+}
 
 /**
  * Implementation of hook_form_alter().
