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.
- Ad or email clickVisitor lands with UTMs
- Page loadsNo HubSpot script in the HTML
- Cookie sethubspotutk never created
- Form submittedContact has no visit history
- Source reportSource unknown or wrong
The visit happens, but HubSpot never hears about it.
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
View the page source
Open the page, right-click and choose View page source. Search for
hs-scripts.comorhs-analytics. Do this on your home page, a landing page and the thank-you page.Check the Network tab
Open browser developer tools, go to Network, reload and filter for
hs-scriptsorhubspot. You should see the script load and requests totrack.hubspot.comorhubspot.com.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.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.
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.
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).
Use the HubSpot app
Install the HubSpot app from the Shopify App Store and connect your account. It adds the code to the storefront.
Or edit the theme
In Online Store, Themes, Edit code, open
theme.liquidand paste the snippet before</head>. Note that this does not cover checkout pages on all plans.
Create a Custom HTML tag
Add a new tag of type Custom HTML and paste the HubSpot snippet.
Set the trigger
Fire it on All Pages. If you use consent mode or a cookie banner, tie it to the right consent category.
Publish the container
Click Submit and Publish. Unpublished changes are a common reason the code stays missing.
Add to custom code
Open Project settings, then Custom code, and paste the snippet in the Head code box. Publish the site.
Add to tracking code
In the funnel or website settings, paste the snippet in the Head tracking code area, then save and republish each funnel that needs it.
Use Custom Code
In Settings, Advanced, Custom code, add a new code snippet, paste the HubSpot script, set it to load on all pages in the Head, and apply. Custom code needs a premium plan with a connected domain.
Use Code Injection
Go to Settings, Advanced, Code Injection and paste the snippet into the Header box. Code injection needs a plan that supports it.
Paste in the head
Add the snippet to the shared layout so it appears on every page. Replace the hub ID with your own.
<!-- 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
- View source or the Network tab shows
js.hs-scripts.com/YOUR_HUB_ID.jsloading once on every key page. - The
hubspotutkcookie 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.
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.
Related issues
- TRK-268HubSpot form submissions not linked to tracked visitor (hutk missing)Fix guide
- TRK-269HubSpot original source shows 'Offline' for web leadsFix guide
- TRK-270UTMs not written to CRM contact fieldsFix guide
- TRK-273Salesforce Pardot / Marketo Munchkin tracking missingFix guide
- TRK-274ActiveCampaign / Mailchimp site tracking missingFix guide
- TRK-278Hidden UTM fields present but emptyFix guide