Skip to content
FunnelGuard

Fix guide by FunnelsGuard

HubSpot tracking code missing: how to find and fix it

TRK-267Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

The HubSpot tracking code is a small JavaScript snippet that loads from js.hs-scripts.com/YOUR_HUB_ID.js. It sets a cookie called hubspotutk in the visitor's browser and sends page views to HubSpot. HubSpot uses this to build a contact's activity timeline and to work out where the contact came from.

Why it costs you leads or sales

Without the code, HubSpot cannot see who visited, which pages they viewed or which campaign brought them. Forms may still submit, but the contact is created without the visit history and often with a poor source. Reports, lead scoring, workflows and sales follow-up that rely on page views all weaken. The impact is usually medium: leads still arrive, but you lose the data to judge which channels work.

Where a missing tracking code breaks the chain
  1. Ad or email clickVisitor lands with UTMs
  2. Page loadsNo HubSpot script in the HTML
  3. Cookie sethubspotutk never created
  4. Form submittedContact has no visit history
  5. Source reportSource unknown or wrong

The visit happens, but HubSpot never hears about it.

Contacts with page view historyExample numbers
Contacts with page view history (example)Code missing: 5 %; Code installed: 90 %03469590Code missingCode installed%

Example: share of new contacts that show page views in HubSpot before and after the code is restored. Numbers are illustrative.

How to check if your site has it

Check a page for the HubSpot code
  1. View the page source

    Open the page, right-click and choose View page source. Search for hs-scripts.com or hs-analytics. Do this on your home page, a landing page and the thank-you page.

  2. Check the Network tab

    Open browser developer tools, go to Network, reload and filter for hs-scripts or hubspot. You should see the script load and requests to track.hubspot.com or hubspot.com.

  3. Check the cookie

    In developer tools open Application (Chrome) or Storage (Firefox), then Cookies. Look for hubspotutk. If you have a cookie banner, accept analytics cookies first.

  4. Use HubSpot's own check

    In HubSpot go to Settings, then Tracking & Analytics, then Tracking Code. The Install tab shows your code and lets you send a test to a domain to verify it.

How to fix it

First copy your tracking code from HubSpot: Settings, Tracking & Analytics, Tracking Code. Use only one install method per site, so the code does not load twice.

Install the HubSpot tracking code
  1. Use the HubSpot plugin

    Install and activate the HubSpot plugin, then connect your HubSpot account from its settings. The plugin adds the tracking code to all pages.

  2. Or add the code to the header

    If you do not use the plugin, paste the snippet in the site header using a header and footer scripts plugin or your theme's header file (child theme recommended).

HubSpot tracking code (replace 12345678 with your Hub ID)html
<!-- Start of HubSpot Embed Code -->
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/12345678.js"></script>
<!-- End of HubSpot Embed Code -->

How to confirm it's fixed

Confirmation checks
  • View source or the Network tab shows js.hs-scripts.com/YOUR_HUB_ID.js loading once on every key page.
  • The hubspotutk cookie is set after you accept analytics cookies.
  • Submit a test form on the site, then open the new contact in HubSpot and check the activity timeline for a page view.
  • HubSpot's Tracking Code install check passes for your domain.
  • Landing pages and thank-you pages show the code too, not only the main site.

How to prevent it happening again

Most losses happen after a change: a theme update, a redesign, a new landing page tool or a tag manager edit. Add a HubSpot check to your release checklist, keep a single install method, and review consent settings when you change your cookie banner. Re-check after any migration or domain change.

Contact record in HubSpot

Code missing

  • No page views on the timeline
  • Source unknown or Direct
  • Hard to score or follow up

Code installed

  • Page views logged per visit
  • Source and campaign captured
  • Workflows and reports work

How FunnelGuard handles this

FunnelGuard detects this only partly. It runs your real journeys on a schedule and captures the tracking hits the pages send. That means it records whether requests go out to HubSpot during a journey. It does not have a HubSpot parser, so it does not read the contents of those hits, check your Hub ID, or confirm that a contact's timeline shows the visit.

Cover the rest by hand. After each release, run the checks above: view source for the script, confirm the hubspotutk cookie, and submit a test form to look at the contact timeline in HubSpot. FunnelGuard's test traffic is marked (utm_source=funnelguard, fg_test=1), so you can find and delete test contacts afterwards. The Free plan covers 1 site and 2 journeys with daily checks and no card, and a free read-only website audit is available.

Questions people ask

Why is my HubSpot tracking code not working?

The most common causes are that the script is not on the page, it loads twice, a cookie banner blocks it, or the Hub ID is wrong. View the page source and search for hs-scripts.com to see which one applies.

How do I check if the HubSpot tracking code is installed?

Open the page source and search for hs-scripts.com, or open developer tools, go to Network and look for the script. You can also check Settings, Tracking & Analytics, Tracking Code in HubSpot and run its install check.

Where do I find my HubSpot tracking code?

In HubSpot go to Settings, then Tracking & Analytics, then Tracking Code. Your code, with your Hub ID, is shown on the Install tab.

Do I need the tracking code if I use HubSpot forms?

Yes, for visitor tracking. Embedded HubSpot forms can submit without it, but without the code the submission is not linked to a browsing history, so source and page view data are poor or missing.

Can I install the HubSpot tracking code with Google Tag Manager?

Yes. Add a Custom HTML tag with the HubSpot snippet, trigger it on All Pages, respect your consent settings and publish the container. Make sure no plugin also loads the code.

Why don't I see page views on a HubSpot contact?

The tracking code may be missing on those pages, blocked by cookie consent, or the visitor was not cookied before submitting the form. Check the script and the hubspotutk cookie on the page they visited.

Can FunnelGuard tell me if the HubSpot code is missing?

Only partly. It captures the tracking hits sent during a journey but has no HubSpot parser, so it does not read or validate them. Check the script and a test contact timeline by hand.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: hit capture; no HubSpot parser.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.