diff --git a/contrib/referral/referral.module b/contrib/referral/referral.module
index 167944f..f92e70c 100644
--- a/contrib/referral/referral.module
+++ b/contrib/referral/referral.module
@@ -143,14 +143,27 @@ function referral_settings() {
 function referral_get() {
   global $user;

+  //get the path after referral
+  $path = explode('/', $_GET['q']);
+  array_shift($path);
+
   if (!$user->uid) {
-    // User has not logged in, or registered yet
-    $uid = _referral_ref2uid(arg(1));
+    // User has not logged in, or registered
+    $uid = _referral_ref2uid(array_shift($path));
     if (($uid) && is_numeric($uid)) {
-      // Set the referral cookie
+      // Set the referral cookie and notify other modules
       referral_set_cookie($uid);
+      module_invoke_all('referral', $uid);
+    }
+
+    //store the destination or default
+    if (!empty($path)) {
+      $dest = implode($path, '/');
+    } else {
+      $dest = variable_get(REFERRAL_GOTO_PATH, 'user/register');
     }
-    drupal_goto(variable_get(REFERRAL_GOTO_PATH, 'user/register'));
+
+    drupal_goto($dest);
   }
   drupal_goto();
 }

