ContactID from HubL?


#1

Hi there,

We’re using the Hubspot COS to power our website - Is there a way to grab the ContactID of a known user using HubL and make it available to client-side javascript?

Put another way, we want to do some measurement/analytics work - what is the best variable/ID that we can use to uniquely identify an individual that is browsing on our website and link them back up to a Hubspot contact record? ContactID (post form submission) would be ideal as that would be cross-browser and cross-device…


#2

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.

Your client-side javascript can read the value of this hubspotutk cookie from the user’s browser, and then you’ll be able to use our Get Contact by utk API to retrieve additional details about the contact associated with that utk.

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.


#3

Hi Comptly,

Would you recommend to create a script that search for every utk and store the contact properties into a database?