diff --git a/classes/log/store.php b/classes/log/store.php
index e81423bcf39caff8f4fe5208fd893a71ed74bffc..9d43e15d061387c4b2272c68f9a3a0d4884504d3 100755
--- a/classes/log/store.php
+++ b/classes/log/store.php
@@ -96,6 +96,7 @@ class store extends php_obj implements log_writer {
                 'source_version' => $CFG->release,
                 'source_lang' => 'en',
                 'send_mbox' => $this->get_config('mbox', false),
+                'send_username' => $this->get_config('username', false),
                 'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
                 'plugin_version' => $plugin->release,
                 'repo' => new \src\transformer\repos\MoodleRepository($DB),
diff --git a/lang/en/logstore_xapi.php b/lang/en/logstore_xapi.php
index aa256683055d655ea47c0d11b49cdfa6be7b4936..a003dd156d213b035177ff53155e924260d15134 100644
--- a/lang/en/logstore_xapi.php
+++ b/lang/en/logstore_xapi.php
@@ -39,5 +39,7 @@ $string['routes'] = 'Include actions with these routes';
 $string['filters'] = 'Filter logs';
 $string['logguests'] = 'Log guest actions';
 $string['filters_help'] = 'Enable filters that INCLUDE some actions to be logged.';
-$string['mbox'] = 'Send user email';
-$string['mbox_desc'] = 'Statements identify the user with its email (mbox) or with its userid on the moodle platform (account). Checking this will send the email (mbox).';
\ No newline at end of file
+$string['mbox'] = 'Identify users by email';
+$string['mbox_desc'] = 'Statements will identify users with their email (mbox) when this box is ticked.';
+$string['username'] = 'Identify users by id';
+$string['username_desc'] = 'Statements will identify users with their username when this box is ticked, but only if identifying users by email is disabled.';
\ No newline at end of file
diff --git a/settings.php b/settings.php
index dec48e6e6b534b40826b920c86bb1609a2fff09f..a8dd420ed2b387c4ee465a43f80d7728a7edd83d 100644
--- a/settings.php
+++ b/settings.php
@@ -42,6 +42,10 @@ if ($hassiteconfig) {
     $settings->add(new admin_setting_configcheckbox('logstore_xapi/mbox',
         get_string('mbox', 'logstore_xapi'),
         get_string('mbox_desc', 'logstore_xapi'), 0));
+    
+    $settings->add(new admin_setting_configcheckbox('logstore_xapi/username',
+        get_string('username', 'logstore_xapi'),
+        get_string('username_desc', 'logstore_xapi'), 0));
 
     // Filters.
     $settings->add(new admin_setting_heading('filters',
diff --git a/src/transformer/utils/get_user.php b/src/transformer/utils/get_user.php
index fa4d7aadde89225b2a1f13ba1c413592f196787e..ac8aea9893a5595e30192c2a9e19a5f77c774e54 100644
--- a/src/transformer/utils/get_user.php
+++ b/src/transformer/utils/get_user.php
@@ -19,18 +19,29 @@ defined('MOODLE_INTERNAL') || die();
 
 function get_user(array $config, \stdClass $user) {
     $fullname = get_full_name($user);
-    if (array_key_exists('sendmbox', $config) && $config['sendmbox'] == true) {
+
+    if (array_key_exists('send_mbox', $config) && $config['send_mbox'] == true) {
         return [
             'name' => $fullname,
             'mbox' => $user->email,
         ];
-    } else {
+    }
+
+    if (array_key_exists('send_username', $config) && $config['send_username'] === true) {
         return [
             'name' => $fullname,
             'account' => [
                 'homePage' => $config['app_url'],
-                'name' => strval($user->id),
+                'name' => $user->username,
             ],
         ];
     }
+
+    return [
+        'name' => $fullname,
+        'account' => [
+            'homePage' => $config['app_url'],
+            'name' => strval($user->id),
+        ],
+    ];
 }
diff --git a/tests/xapi_test_case.php b/tests/xapi_test_case.php
index 1b1c21b9e1236ce2620e92c242e804ca722dccee..6883e5bf8090cfd1f7ccc6477f320e4c90e53244 100644
--- a/tests/xapi_test_case.php
+++ b/tests/xapi_test_case.php
@@ -75,6 +75,7 @@ abstract class xapi_test_case extends PhpUnitTestCase {
             'source_version' => '1.0.0',
             'source_lang' => 'en',
             'send_mbox' => false,
+            'send_username' => false,
             'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
             'plugin_version' => '0.0.0-development',
             'repo' => new \src\transformer\repos\TestRepository($testdata),