Handling anonymous orders in custom commerce module
Perhaps you could use PHP's session_id()?


  session_id() is used to get or set the session id for the current session.


Basically copied from this answer.



You may also find useful information here: Anonymous Personalization Without Leaving Drupal, which appears to be a topic from DrupalCon Seattle 2019.