Overview
HubSpot is an all-in-one CRM, marketing automation, sales, and customer service platform widely used by inbound marketing teams. Its tracking code is one of the most commonly deployed marketing scripts on the web. HubSpot scripts serve multiple functions simultaneously: visitor tracking and identification, marketing attribution, live chat, forms, and CRM contact enrichment.
What This Script Does
HubSpot's tracking code (hs-script-loader) loads multiple subsystems:
Tracking and Analytics
- Tracks every page view with full URL, referrer, and timestamp
- Records form submissions (both HubSpot forms and native HTML forms when configured)
- Captures UTM parameters and marketing attribution data (source, medium, campaign)
- Monitors CTA clicks and content interactions
- Fires custom behavioral events when configured via the HubSpot API
Cookies Set
__hssc— session cookie tracking current session page view count (30-minute expiry)__hssrc— session cookie detecting new sessions vs. tab reopens__hstc— persistent cookie (13 months) containing visitor ID, first visit timestamp, last visit timestamp, current session timestamp, and session count. This is the primary tracking cookie.hubspotutk— persistent cookie (13 months) storing the visitor's unique identity token. This value is sent to HubSpot when a form is submitted, linking anonymous browsing history to a known contact in the CRM.__hs_opt_out— stores cookie consent banner response__hs_do_not_track— respects Do Not Track settings when enabled__hs_initial_opt_in— tracks initial consent statemessagesUtk— persistent cookie for chat widget visitor identification
Live Chat (HubSpot Conversations)
- Loads the chat widget when configured
- Sets
messagesUtkto identify returning chat visitors - Tracks which pages the visitor viewed before starting a conversation
- Sends browsing context to agents in real time
Forms
- Renders HubSpot-hosted forms or enhances native forms with tracking
- Pre-fills form fields for returning visitors when identity is known
- On submission, links all prior anonymous browsing history to the contact record in HubSpot CRM
Network Requests
- Sends tracking data to
track.hubspot.comandforms.hubspot.com - Loads chat widget resources from
app.hubspot.com - Downloads form definitions and configuration from HubSpot CDN
- May load additional scripts for A/B testing, ads tracking, or integrations depending on HubSpot portal configuration
Consent & Compliance
- Consent categories: Marketing (visitor tracking, attribution, CRM identification), Analytics (page views, behavioral events), Functional (live chat, forms)
- GDPR/ePrivacy: HubSpot sets multiple persistent cookies with long expiration periods (up to 13 months) that track visitors across sessions and link anonymous behavior to identified contacts. Requires explicit opt-in consent under both ePrivacy Directive and GDPR. HubSpot provides a built-in cookie consent banner, but if a third-party CMP is used, the tracking code must be gated behind consent.
- CCPA: Visitor tracking data, behavioral profiles, and contact enrichment constitute personal information. Requires prominent disclosure. The
hubspotutkcookie specifically enables cross-session identification, which falls under PI definitions. - Data Processing: HubSpot acts as a data processor. A DPA is available in HubSpot account settings and should be executed.
- Consent granularity: HubSpot's tracking code loads as a single script that enables all features simultaneously. For granular consent (e.g., allow chat but block tracking), the HubSpot consent API or conditional loading at the CMP level is required.
Because HubSpot serves marketing, analytics, and functional purposes simultaneously, there are several approaches to consent management: (1) Block everything until marketing consent — the simplest approach, treating the entire script as marketing since tracking is its primary function. (2) Use HubSpot's consent API — load the script but call _hsq.push(["doNotTrack"]) until consent is granted. (3) Conditional feature loading — if only chat is needed, the HubSpot Conversations API can be deployed independently without the full tracking code.
Should You Block This Without Consent?
Yes. HubSpot's tracking code sets persistent identification cookies, tracks page views across sessions, and builds behavioral profiles linked to CRM contacts. Even when used primarily for its chat or forms features, the default tracking code includes full visitor monitoring. It should not load until the user has granted at least marketing consent. If chat functionality is needed without tracking, the Conversations widget can be deployed separately using HubSpot's standalone chat embed.
Is HubSpot GDPR compliant?
HubSpot typically loads analytics, marketing and functional trackers, which are not strictly necessary for your site to work. Under the GDPR and the ePrivacy Directive, non-essential cookies and trackers must stay blocked until a visitor gives clear opt-in consent. So HubSpot can be fully GDPR compliant, but only if your site holds its scripts until consent is granted and lets visitors decline just as easily. Compliance depends on how your site loads HubSpot, not on HubSpot itself.
Products (9)
Consent Categories
Also Known As
Industries
Tracked Domains (12)
HubSpot's trackers are occasionally seen, seen on about 2% of the sites ConsentStack has scanned. Scan your own site to see which of these are firing before consent.
hs-analytics.netAnalyticshs-analytics.net is an analytics domain operated by HubSpot, used to measure visits, sessions, and on-site behavior. Seen on about 2% of scanned sites.
hs-scripts.comMarketinghs-scripts.com is a marketing domain operated by HubSpot, used to serve ads, build audiences, and measure ad conversions. Seen on about 2% of scanned sites.
hubspot.comMarketinghubspot.com is a marketing domain operated by HubSpot, used to serve ads, build audiences, and measure ad conversions. Seen on about 2% of scanned sites.
hsforms.comAnalyticshsforms.com is an analytics domain operated by HubSpot, used to measure visits, sessions, and on-site behavior. Seen on about 2% of scanned sites.
hsadspixel.netMarketinghsadspixel.net is a marketing domain operated by HubSpot, used to serve ads, build audiences, and measure ad conversions. Seen on about 1% of scanned sites.
hubapi.comMarketinghubapi.com is a marketing domain operated by HubSpot, used to serve ads, build audiences, and measure ad conversions. Seen on about 1% of scanned sites.
usemessages.comFunctionalusemessages.com is a functional domain operated by HubSpot, used to run site features like chat, video, embeds, and preferences. Seen on under 1% of scanned sites.
hsleadflows.netAnalyticshsleadflows.net is an analytics domain operated by HubSpot, used to measure visits, sessions, and on-site behavior. Seen on a small share of scanned sites.
hubspotusercontent.comMarketinghubspotusercontent.com is a marketing domain operated by HubSpot, used to serve ads, build audiences, and measure ad conversions.
hubspotlinks.comAnalyticshubspotlinks.com is an analytics domain operated by HubSpot, used to measure visits, sessions, and on-site behavior.
hubspot.netMarketinghubspot.net is a marketing domain operated by HubSpot, used to serve ads, build audiences, and measure ad conversions.
hscollectedforms.netMarketinghscollectedforms.net is a marketing domain operated by HubSpot, used to serve ads, build audiences, and measure ad conversions.
Cookies HubSpot Sets (11)
__hstcHubSpot main analytics tracking cookie storing visitor and session counts plus first/last visit timestamps. 13-month expiration.
__hsscHubSpot session pageview-counter cookie. 30-minute expiration.
hubspotutkHubSpot user token identifying the visitor; passed to HubSpot CRM and chat to associate activity. 13-month expiration.
__hssrcHubSpot session-restart marker; signals whether the visitor restarted their browser. Session-only.
__hsfpHubSpot fingerprint hash used to deduplicate the visitor across cookies. Session-only.
messagesUtkHubSpot Conversations visitor identifier linking a chat conversation to the same visitor across sessions. 13-month expiration.
__hs_opt_outEssentialHubSpot opt-out marker preventing the user from being asked again to accept cookies. 13-month expiration.
hs-messages-is-openHubSpot signals whether the in-page chat widget is open. Session-only; written when HubSpot live chat loads.
__hs_do_not_trackEssentialHubSpot Do Not Track marker disabling tracking entirely for this visitor. 13-month expiration.
__hs_cookie_cat_prefEssentialHubSpot per-category consent preferences (analytics / advertising / functionality). 13-month expiration.
__hs_initial_opt_inEssentialHubSpot first-visit opt-in marker preventing the cookie banner from re-appearing for the same visitor.
Frequently Asked Questions
Related Vendors
Manage consent for HubSpot
ConsentStack automatically detects and manages HubSpot trackers so your site stays compliant with global privacy regulations.