HubSpot Cookie

Hi,

Is there any way out to decrypt HubSpot cookies properties data? We are a HubSpot partner & using HubSpot cookie banner & want to use the HS cookie in our website but it’s in Encrypted form.
Please suggest the way-out.

Thanks

Pankaj Sharma

Hi @PSharma20med,

To my knowledge the HubSpot cookie isn’t encrypted. It provides a unique value which is stored as the UTK assigning browsing data to your visitors when they come across your pages which have the HubSpot tracking code.

To get the cookie itself from each visitor you can refer to this post I replied to which shows how to retrieve this using a script. The utk is most commonly used in the Forms API to pass the information into HubSpot when working with external forms.

To my knowledge I have not seen any endpoints that provide contact data based on the utk value. In terms of tracking a unique value and assigning it to a contact, this article might shed some light here.

Let me know how exactly you’re planning to use the cookie in this case to provide further context if the above isn’t what you’re looking for!

Hi,
Thanks for your response. it’s a nice information shared by you. But my requirement is little bit different i am explaining it. We have cookie in HubSpot “__hstc” it has few properties like: initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit). how I can read the data for these properties in datetime format?
looking for positive response.

Thanks

Hi @PSharma20med!

Thanks for the added context here!

When I check the cookies as I access a page with the HubSpot tracking code, I can spot the cookie coming through as the following:

__hstc=177999999.955595516594f3568f0fe66e85eee750.1693123835137.1693123835137.1693123835137.1

From the documentation we know:

  • It contains the domain, hubspotutk, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).

Using this information, I can split the cookie above like so:

domain: 177999999 → as far as I can tell, this corresponds with an internalId
hubspotutk: 955595516594f3568f0fe66e85eee750
initial timestamp (first visit): 1693123835137
last timestamp (last visit): 1693123835137
current timestamp (this visit): 1693123835137
session number: 1

In my case, the timestamps all align with the date that I visited the page as it was the first recorded visit for this particular cookie. The timestamps are in epoch timestamps so you can use an epoch converter like https://www.epochconverter.com/ to get the datetime value of the timestamps!

You can also use Javascript to perform this conversion as seen here. One thing to note about these timestamps is that they are 13 digit epoch timestamps so do keep that in mind for your conversion!

Let me know if that’s closer to what you were looking for here :slightly_smiling_face:

Thanks for your suggestion.

Hi,

Can we use HubSpot Necessary cookies in our website? if yes, then please suggest how?

Thanks

Hi @PSharma20med,

As long as you’re using the HubSpot tracking code, HubSpot would set the cookies in the visitor’s browser for any pages they access that have the tracking code. This includes the necessary cookies found here as well as other cookies all highlighted on that page.

Do you have an example page with the tracking code that doesn’t have HubSpot cookies available?

Hi,
Thanks for your response. i want to access below mentioned cookies in my website but when i am trying to access them getting “undefined”:
__hs_opt_out
__hs_do_not_track
__hs_initial_opt_in

Please suggest the way-out to read them?
Thanks

Hi @PSharma20med,

Thanks for the reply! It sounds like your cookie policy might not be enabled to allow opt-in yet per the steps here. The cookies above all related with the consent policy:
__hs_opt_out:

  • This cookie is set when you give visitors the choice to opt out of cookies.

So if you’re not giving visitors that choice, then that cookie itself would not get set.

__hs_initial_opt_in:

  • This cookie is used to prevent the banner from always displaying when visitors are browsing in strict mode.

These are just two examples but I believe adjusting your cookie banner policy might help surfacing these cookies :slightly_smiling_face:

Can I track `hs_login_email` cookie?