APIs & Integrations

benjaminjcharlt
Participant

How can I access a web site visitor's HubSpot contact ID from my web site?

Hi!

 

The web site has the HubSpot tracking code embeded in every page like this:

 

<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/1234567.js"></script>

 

Is it possible for me, in our web site code, to retrieve the cookie that tells me the HubSpot contact ID of the current visitor?

 

Thank you


Benjamin

0 Upvotes
3 Replies 3
dennisedson
HubSpot Product Team
HubSpot Product Team

How can I access a web site visitor's HubSpot contact ID from my web site?

Cool!

You probably will want to reference  the get contact by user token endpoint

Going to throw a couple folks at this who will be able to give some perspective on this  --  @Kevin-C , @tjoyce any thoughts here?

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

How can I access a web site visitor's HubSpot contact ID from my web site?

Hello @benjaminjcharlt !

If you look at this doc , you will see a list of all of the possible cookies that can be set.  You are looking for the hubspotutk cookie which stores the folllowing:

  • This cookie keeps track of a visitor's identity. It is passed to HubSpot on form submission and used when deduplicating contacts.
  • It contains an opaque GUID to represent the current visitor.
  • It expires in 13 months.

Hope this helps!

 

0 Upvotes
benjaminjcharlt
Participant

How can I access a web site visitor's HubSpot contact ID from my web site?

Yes, that's right, Dennis. This is exactly the document that prompted my question.

 

How do I get hold of this opaque GUID on the browser, and convert it into the actual integer contact ID so that I can query the HubSpot API for details about the site visitor?

 

Many thanks


Benjamin