By retrieving the HubSpot session id, are you looking to track visitor actions on your website? If that's the case, the HubSpot Tracking Code helps to capture those website analytics.
Tracking code has already been installed for our website. Now i need to extract any kind of tracking id hubspot uses to track a user. Is there an api that will allow me to extract hubspot tracking id.
As per this documentation here - Cookies set in a visitor's browser by HubSpot, the HubSpot tracking code doesn't have a tracking id. We use the hubspotutk to keep track of a visitor's identity. Hence, extracting tracking id isn't currently possible.
That said, do you mind sharing with me your end goal here? We could possibly explore other options for your use case.