There's a new version of the HubSpot API

As of November 30, 2022, HubSpot API keys are no longer a supported authentication method for accessing HubSpot APIs. Instead, you should use a private app access token or OAuth to authenticate API calls. Learn more about this change and how to migrate an API key integration to use a private app instead.

Get cross-domain linking parameters

Last updated June 17, 2020

_hsq.push(['addIdentityListener', function(hstc, hssc, hsfp) {}])

Allows you to get the parameters needed to create cross-domain links. This will allow you to build links that support cross-domain tracking for links added after the page loads, or links that function using JavaScript instead of standard anchor tags. 

The HubSpot tracking code can be used across multiple sites with separate domains. This function will allow you to get the query parameters required to create create links that will allow you to track your visitors across those separate domains. These query parameters are used by the HubSpot tracking code to identify a visitor across domains by ensuring that the separate cookies for the separate domains are merged to a single tracked visitor.

Note: Cross-domain links are only needed when linking to a distinct domain (e.g., thisdomain.com and anotherdomain.com) that is also being tracked for a single HubSpot account. HubSpot tracking cookies are set at the domain level (.thisdomain.com), so visits between subdomains (www.thisdomain.com and blog.thisdomain.com) should not need the cross-domain link parameters.

Note: Cross-domain links are automatically set up by the HubSpot tracking code on load, so you should only need to update links that are dynamically added to the page after the tracking code is loaded.