When the HubSpot tracking code isn't recording website visits, the code is usually missing from the pages people visit, or something on the page stops it from loading or firing. HubSpot's own troubleshooting steps point to cookie consent tools, ad or script blockers, Content Security Policy rules and tag manager settings. Sometimes the code works and the visits are filtered out, for example because you're testing from an excluded IP address.
The first check is quick. In your tracking code settings, enter a page URL under Validate your tracking code and HubSpot emails you the result. Then open that page, open your browser's developer tools and go to the Network tab. Look for a file named after your Hub ID, such as 123456.js, with a 200 or 304 status, and a __ptq.gif request with 200 OK. If both are there, the code is firing.
Why the HubSpot tracking code isn't tracking visits
The code isn't on every page
HubSpot adds the tracking code to its own website pages, landing pages and blog posts automatically. Pages hosted elsewhere need it pasted before the closing body tag, ideally in a footer or template file every page uses. Check it again after theme changes and new templates. View the page source and search for your Hub ID followed by .js. On WordPress, HubSpot recommends its WordPress plugin, which installs the code for you. The tracking code isn't supported on AMP pages, and files served from HubSpot's files tool never count as page views.
Google Tag Manager isn't firing the tag
Code loaded through Google Tag Manager doesn't show in the page source, so a source check gives a false alarm. Use GTM's Preview mode, select the first Page View event and confirm the HubSpot tag appears under Tags Fired. HubSpot's install steps use a Custom HTML tag with an All Pages trigger, and they say a tag without a firing rule won't fire at all. Their steps end with publishing the container.
Two tracking codes on one page
Only one HubSpot tracking code should be on a page. If there are several, the first one to load fires and the rest don't, so a leftover code from an old HubSpot account can stop your current one from running if it loads first. Installing the WordPress plugin and also pasting the code by hand can cause errors such as duplicate data. Compare the Hub ID in the code with the one shown under your account name.
Cookie consent is limiting what's tracked
If a visitor declines cookies, HubSpot's developer docs say the tracking code can still load and count page views in aggregate, but it won't tie them to a visitor or contact. So traffic totals can look normal while contact records show no page views. If you use a third-party consent tool, the consent banner API shows how to pass the visitor's choice to HubSpot with setHubSpotConsent, or turn off HubSpot's own banner with window.disableHubSpotCookieBanner. Test in a private window, accept cookies and watch the console for errors.
Your own visits are excluded
IP addresses listed under IP Addresses to Exclude on the Advanced Tracking tab are left out of page views, sessions, form views and other analytics. A visitor from an excluded IP gets a cookie that isn't linked to a contact, so testing from the office won't show on your own contact record. New exclusions take up to ten minutes to apply, and they don't remove past traffic.
The domain isn't set up in HubSpot
If the code fires but no sessions appear, HubSpot points to your domain settings. Add externally hosted domains and subdomains under Additional site domains on the Advanced Tracking tab. If Limit tracking to these domains is on, make sure the list includes every domain you want counted. For sites on more than one domain, Automatic cross-domain linking lets HubSpot follow a visitor between them. Without it, the visit to the second domain shows as direct traffic.
The contact was never linked to the cookie
HubSpot tracks visitors anonymously and links their earlier page views to a contact when they submit a HubSpot form. Clicking a tracked marketing email also links page views. Contacts you imported, created by hand or synced from another tool show no page views until one of those happens. Forms that submit server-side or through a proxy without passing the hubspotutk cookie can't make that link. Non-HubSpot forms also need the tracking code on the page, as covered in non-HubSpot forms not captured.
A single-page app only logs the first page
The tracking code records a page view when it first loads. In a single-page application, call setPath and trackPageView from the tracking code API each time the route changes.
How to fix it
- Copy the code from your tracking code settings. On Marketing Hub Starter or the free tools that's Tracking Code in the settings sidebar. On other plans, it's under Tracking & Analytics, then Tracking code.
- Install it once on every page hosted outside HubSpot, in a shared footer or through GTM with an All Pages trigger, then publish.
- Run the validator, then confirm your Hub ID file and
__ptq.gifload in the Network tab. - If the script doesn't load, check the browser console for errors from consent tools, script blockers, Content Security Policy or tag manager rules.
- On the Advanced Tracking tab, add external domains, review Limit tracking to these domains, and turn on cross-domain linking if you run several domains.
- Review your IP exclusions, then test from another network in a private window with cookies accepted.
- Submit a HubSpot form with a test email address and check that the new contact shows the page views from that visit.
How to stop it happening again
Add a tracking check to every website release, theme change and new consent tool. Keep the code in one place, either the site footer or GTM, and write down which. Update the excluded IP list when your office network changes.
From client work
For Kingstown College, I set up tracking for the website and application pages through Google Tag Manager, updated the cookie categories and added Google Ads conversion events as part of their Marketing Hub build. Read the Kingstown College case study.
If the code checks out and visits still don't show up, book a free 30-minute call and we'll trace it on your site together.
Questions
Why don't page views show on contacts I imported?
HubSpot can't link page views to imported, manually created or synced contacts until they submit a HubSpot form or click a tracked marketing email. After a form submission, earlier visits from that browser are added to the record.
Does HubSpot count visitors who decline cookies?
Their page views are still counted in aggregate in traffic analytics, but they aren't tied to a visitor or a contact record.
Do I need a paid plan for the tracking code?
No, the tracking code works on all plans. As of October 2026, the traffic analytics tool needs Marketing Hub or Content Hub Professional or Enterprise.
Did this fix it?
Good to hear. If something else in the portal looks off, the help centre has more fixes.
Some problems need someone to look inside the portal. Book a free 30-minute call and show me what's happening. If it needs work, you get a written scope and one fixed price.