Skip to content

Troubleshoot the HubSpot tracking code

Last updated: November 16, 2026

Available with any of the following subscriptions, except where noted:

The HubSpot tracking code allows HubSpot to track visitors to your site and gather traffic analytics in your account. If you don't see any website traffic data, make sure that the tracking code is installed and working correctly by following the steps below.

Please note: if the tracking code is not installed or working correctly, HubSpot can't reliably receive tracking data from that page. As a result, any data that depends on tracking, such as page views or visitor events, may be incomplete or unavailable. Additionally, features that rely on tracked sessions, such as chat widgets or rule-based chatbots, may not work as expected. HubSpot can't recover tracking data that was missed while the code was inactive. 

Verify the tracking code has been installed

There are two ways to test your tracking code installation: Automatic and manual validation. HubSpot provides an automated tool to validate your installation. HubSpot-hosted pages are tracked by default and do not need manual tracking-code installation. The validator is intended for external pages with the tracking code installed.

To run the automatic checker against your webpage: 
  1. Click the settings settings icon in the top navigation bar.
  2. Navigate to the Tracking & Analytics settings: 
    • In accounts that only have access to Marketing Hub Starter or HubSpot's free tools, navigate to Tracking Code in the left sidebar menu. 
    • For all other subscriptions, navigate to Tracking & Analytics > Tracking code in the left sidebar menu.
  1. Enter the url for your webpage in the Validate your tracking code section. HubSpot will automatically test your webpage and email you the results.

Tracking code validator

Some websites may not be testable with the automatic tool or may provide a false failure result. The validator uses an automated headless browser to visit the page and wait for the tracking pixel to fire. A cookie consent tool may prevent the pixel from firing during the test if consent has not been accepted. Cloudflare can also block the checker even when tracking works for visitors. The validator is informational; a Failed result does not block or affect the tracking code.

For sites using react-cookie-consent, support is now available in the validator. Re-run validation if an earlier test misidentified the consent banner or reported missing tracking code.

If you suspect a false failure, validate your installation manually using the steps below:

  1. Verify your Hub ID by clicking your account name in the top right of your account.
  2. Open a page on your website and right-click anywhere on the page.
  3. In the dropdown menu, select View page source or View source.
  4. Use Ctrl + F or Cmd + F and search for [your Hub ID].js (e.g., 401264.js). 

Please note:

  • You may see the HubSpot Embed Code or Async HubSpot Analytics Code. These are both HubSpot tracking codes and indicate that your tracking code has been installed.
  • If you're using Google Tag Manager or another script loader, the tracking code will not appear in the page source. The tracking code will appear if you’re using the WordPress plugin as long as you don’t have a conflicting plugin installed.
  • If hs-scripts.com is absent from the raw page source, check the browser's Elements panel. If it appears there, the code is being injected dynamically and the automatic validator may not detect it. Use the manual loading and firing checks below to verify tracking.
  • If the tracking code was installed through Google Tag Manager, use Preview mode to connect to the page, select the first Page View event, and confirm that the HubSpot tracking tag appears under Tags Fired.

 

  • If the tracking code appears, verify that the code has been copied and pasted correctly from your account settings. To check the tracking code in your HubSpot account: 
    1. Click the settings settings icon in the top navigation bar.
    2. Navigate to the Tracking & Analytics settings: 
      • In accounts that only have access to Marketing Hub Starter or HubSpot's free tools, navigate to Tracking Code in the left sidebar menu. 
      • For all other subscriptions, navigate to Tracking & Analytics > Tracking code in the left sidebar menu. 
      • The tracking code is in the Embed code section. 
  • If the tracking code does not appear in the page source or Elements panel, is not installed through a script loader, or the page is not HubSpot-hosted, install the tracking code

Verify that the tracking code is loading correctly

If your tracking code has been installed correctly and appears on the page, you need to verify that the tracking code is loading:

  1. Open a page on your website in your browser, accept consent if the site is consent-gated, and right-click anywhere on the page.
  2. In the dropdown menu, select Inspect Element or Inspect. A toolbar will appear at the bottom or side of your screen.
  3. Click the Network tab, then refresh your page.
  4. Click the Name column to sort the elements alphabetically, then scroll to the top of the list.
  5. In the Name column, look for [your Hub ID].js (e.g., 401264.js). Under the name, you may see from js.hs-scripts.com and/or an instance of this .js element from js.hs-analytics.com.
  6. Next to [your Hub ID].js, you should see 304 Not Modified or 200 OK in the Status column.
network-tab-trakcing-code-item
If you see a different status or the JavaScript code is not found, your tracking code may not be firing correctly. Check the browser console for JavaScript errors or blockers, including cookie consent tools, ad or script blockers, Content Security Policy restrictions, or tag manager rules.
Contact HubSpot Support for further troubleshooting and assistance.

Please note: it is expected to see both hubid.js from js.hs-scripts.com (the script loader) and hubid.js from js.hs-analytics.net (the tracking script) in the Network tab. If you use chatflows on your site, you may also see a third script,  hubid.js from api.usemessages.com/messages.

It is also expected to see the  js.hs-banner  script loading in the Network tab, even if you aren't using the HubSpot's Cookie Consent Banner, as the script is responsible for placing HubSpot's cookies in your visitors' browsers. 

If the script loader js.hs-scripts.com is present, also check for the tracking script js.hs-analytics.net to ensure that the code is firing correctly. If you only see the actual tracking script js.hs-analytics.net and not the script loader, the tracking code will still fire correctly.

 

Verify that the tracking code is firing correctly

If your tracking code is installed, appears on the page, and is loading, verify that the tracking code is firing correctly:

  1. Open a page on your website in your browser, accept consent if the site is consent-gated, and right-click anywhere on the page.
  2. In the dropdown menu, select Inspect Element or Inspect. A toolbar will appear at the bottom or side of your screen.
  3. Click the Network tab, then refresh your page.
  4. Click the search bar and enter __ptq.gif
  5. In the Name column, look for __ptq.gif
  6. Next to __ptq.gif you should see 200 OK in the Status column.

Network tab screenshot to verify tracking code is firing correctly

Successful tracking requests and page views or sessions in HubSpot traffic analytics confirm that data is being collected. If Cloudflare blocked validation but tracking requests continue loading successfully, you can disregard the failed automatic test.

If the HubSpot tracking code is loading and firing on your website pages, but you do not see any new page views or sessions on your dashboard or in the sources report, you may need to change your target domain or add additional domains to your tracking code settings to make sure that HubSpot is gathering analytics from the correct domain or subdomain.

Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.