Blog · UTMs and tracking

How to check the HubSpot tracking code is firing on a page

Five checks in the browser and in HubSpot that tell you whether the tracking code loads on a landing page, and why it is the first thing to rule out.

Kurt Kalwin6 min read

To check the HubSpot tracking code is installed and firing, open the page, search its source for your Hub ID followed by .js, then watch the Network tab for that file and a __ptq.gif request. If both load and the hubspotutk cookie appears, the code is running. If the source looks right but nothing loads, look for an ad blocker, a consent banner or a second copy of the code.

Check the code before you blame the sources

When a webinar's registrants show up in HubSpot as Offline sources or Direct traffic, the first thing I check is whether the landing page carried the tracking code at all. Every Original Source rule depends on it. No script, no page view, no UTM parameters read, and the contact gets whatever HubSpot can work out from the form submission alone.

On setup calls this is the cause more often than any UTM mistake. A new landing page template, a page builder swapped last month, a tag manager container someone tidied: each of these can drop the script without anyone noticing, because the page still looks fine. The post on how HubSpot reads UTM parameters covers what happens once the code is there. This post is about making sure it is.

It takes five minutes. Do it before you rebuild a report or retag a campaign.

The checklist, in the browser

Use a normal browser window with extensions off, or a private window. Open the exact landing page your links point to, not the home page.

  1. View the page source and search for your Hub ID followed by .js. HubSpot's tracking code troubleshooting page gives this as the first check. You should also find a script tag with the id hs-script-loader.
  2. Open developer tools, go to the Network tab and reload. Look for the script loader from js.hs-scripts.com and the tracking script from js.hs-analytics.net. A status of 200 or 304 means it loaded.
  3. In the same Network list, look for a request to __ptq.gif. HubSpot's page says it should return 200 OK. This is the page view being sent, which is the part that matters.
  4. Open the Application or Storage tab and look at cookies for the page's domain. You want hubspotutk and __hstc. HubSpot's list of cookies it sets describes hubspotutk as the visitor's identifier, sent to HubSpot when a form is submitted, and __hstc as the main tracking cookie.
  5. Open the Console tab and read any red errors that mention HubSpot domains. A blocked script usually names itself here.

If steps 1 to 4 all pass, the code is firing on that page. Stop looking at the page and start looking at the links.

When the source looks empty but the code is there

If you install the code through Google Tag Manager, step 1 will fail even on a working page. HubSpot's troubleshooting page says the code does not appear in the page source when a tag manager loads it. Use Tag Manager's Preview mode instead and confirm the HubSpot tag is listed under Tags Fired on the first page view.

HubSpot's installation page adds the other half of that: a Tag Manager tag with no firing trigger never fires, and no analytics data is collected. A tag that exists in the container is not the same as a tag that runs. I have seen this one more than once, usually after someone cleaned up triggers they did not recognise.

What stops a correctly installed code

The code can be on the page and still not run. HubSpot's pages list a few causes, and they are worth checking in this order.

  • A consent banner. If the visitor has not accepted cookies, HubSpot's analytics cookies may not be set. Test with consent given, then without, so you know what each visitor gets.
  • An ad blocker or privacy extension. These block HubSpot's domains on your own machine and make a working page look broken. This is why the checklist starts in a clean window.
  • A Content Security Policy. If your site sends one that does not allow HubSpot's domains, the browser refuses the script and the Console says which one.
  • Two copies of the code. HubSpot's troubleshooting page says only the first tracking code on a page loads when there are several, which matters when a page carries both a hardcoded snippet and a tag manager version from different portals.
  • Another element using the hs-script-loader id. HubSpot uses that id to avoid loading the script twice, so a page that reuses it elsewhere can skip the real script.

Ad blockers are the one you cannot fix. Some share of your real visitors will never send a page view, and their registrations will reach HubSpot as form submissions without the visit history. Accept that and move on; it is not a setup error.

Use HubSpot's own validator too

HubSpot has a checker in the tracking code settings. HubSpot's installation page describes it under Settings, Tracking and Analytics, Tracking code: enter a page URL under Validate your tracking code and HubSpot tests it. The same page warns it can report a failure on sites where the code works, so I treat it as a second opinion. The browser checks above are what I trust.

The page you cannot check: zoom.us

If your registration link points at a zoom.us page, none of this applies, because your HubSpot tracking code does not run on Zoom's pages. UTM parameters on a Zoom registration link never reach the HubSpot contact. The post on Original Source and webinars walks through what that does to your reports.

The fix is not on Zoom's side. Put the registration form on a page you own, run the checklist above on that page, and send every tagged link there. The post on registration pages that track source covers that page.

A worked example: one landing page, two results

Say you launch a webinar page at yoursite.com/webinars/q1-pipeline and a week later the registrants report shows most of them under Direct traffic, though every link you sent was tagged utm_medium=email with the UTM builder.

You open the page in a private window and view the source. No Hub ID .js, no hs-script-loader. Your blog pages do have it. The difference is that the webinar page was built on a new landing page template, and the template's footer, where the snippet lived, was replaced.

You add the code back to the template, reload, and see js.hs-scripts.com, js.hs-analytics.net and __ptq.gif all return 200. The hubspotutk cookie appears. You submit a test registration through the newsletter link and the test contact's Original Source reads Email marketing.

The registrants from the first week stay as they are. Original Source is set when HubSpot first tracks a contact, and fixing the page later does not rewrite it. Note the date of the fix beside the report so nobody compares the two weeks as if they were measured the same way.

Questions people ask

Does the tracking code need to be on the thank-you page?

It needs to be on the page with the form, because that is where hubspotutk is read and sent with the submission. I put it on the thank-you page as well, since it costs nothing and keeps the visit history complete.

Why does HubSpot show my own visits but not my visitors'?

Usually it is the reverse problem: your own browser has consent given and no blocker on that profile, while many visitors decline cookies or block scripts. Test with consent declined to see what they see.

Will a HubSpot form embedded on a page without the code still work?

A HubSpot form will still create the contact, but the page views and the source that come with a tracked visit are lost. A form that is not HubSpot's is worse off: HubSpot's page on non-HubSpot forms says it can only collect those submissions when the tracking code loads.