To Add User - make sure you wrap in a window.on('load') function
You should add to the API that all JavaScript to SetAttributes should be wrapped in a window on load function to prevent asynchrenous loading. Took me a minute to figure out the real issue...so here is some sample code in WordPress to easily add in the username and email in a WordPress installation:
<?php
function addusertotawk() {
if (isuserloggedin()) {
$currentuser = wpgetcurrentuser();
$tawkhash = hashhmac('sha256', $currentuser->useremail, MYAPIKEY);
$html = "<script type='text/javascript'>jQuery(window).on('load', function(){
const visitor = {
name : '{$currentuser->userfirstname} {$currentuser->userlastname}',
email : '{$currentuser->useremail}',
hash : '" . $tawkhash . "'
}; TawkAPI.setAttributes(visitor); }); </script>";
echo $html;
}
?>
}
Sorry for the bad formatting, this text area is terrible.

-
Alex Seidler commented
Not sure how to edit but you could easily add this directly under the end of the function }
(last line of code)::add_action( 'wp_footer', 'add_user_to_tawk' );