I mostly work with our APIs and am not super familiar with the HubL side of things, but if your goal is to uniquely ID a visitor on your site & tie it to a contact record, I think I can help.
When someone visits a website with the HubSpot tracking code installed on it, we set a cookie called “hubspotutk” on that visitor for analytics tracking purposes. When that visitor converts to a contact, we associate that cookie with the contact record in HubSpot. Since contacts might use multiple devices or browsers to engage with your content, there can be multiple hubspotutk cookies associated with a single contact record at any given time.
One thing to note is that our Contact API does not support CORS, so to call it you’ll need to spin up a proxy server or run that part of the code server-side.