Track HubSpot Form Submissions and Store Count Locally

I have a WordPress site with a HubSpot form embedded using their JavaScript snippet. I need to count how many times users submit this form and store that number locally.

When I look at the browser’s developer tools, I can see the form data being sent:

user_email: [email protected]
mobile: 9876543210
first_name: john
last_name: doe
organization: 
location:

The server returns a 200 status code. The submission goes to a URL like:

https://forms.hsforms.com/submissions/v3/public/submit/formsnext/multipart/1234567/abc123-4def-56gh-78ij-9klmnop0qrst

Since this doesn’t seem to be an AJAX request, I’m not sure how to intercept it. How can I detect when the form gets submitted so I can increment my counter?

Yeah, HubSpot forms definitely trigger JavaScript events you can catch. Their embedded API fires callbacks you can hook into. Just add an onFormSubmit callback function to your HubSpot form code - it’ll run every time someone submits. Increment your counter in there and store it in localStorage or sessionStorage (depends if you want it to stick around after they close the browser). I’ve used this on multiple client sites and it’s solid. The callback gets the form data too, so you can do conditional counting based on specific fields if you want. Just handle cases where localStorage might be disabled or full, and maybe add timestamps to track submission frequency.

Hit this exact issue last month with a client’s landing page. The trick is watching network requests directly - HubSpot forms submit via XHR even when it’s not obvious in dev tools. I wrapped XMLHttpRequest.prototype.send to catch requests going to forms.hsforms.com. When you get a successful response, just bump your counter in localStorage. Works across all HubSpot form setups. Here’s what worked for me: javascript const originalSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function(data) { this.addEventListener('load', function() { if (this.responseURL.includes('forms.hsforms.com') && this.status === 200) { let count = parseInt(localStorage.getItem('formSubmissions') || '0'); localStorage.setItem('formSubmissions', (count + 1).toString()); } }); return originalSend.call(this, data); }; This catches submissions no matter how HubSpot handles the form internally and doesn’t depend on their API callbacks, which can be flaky depending on how you embed the form.

Been there. JavaScript tracking solutions always break eventually - ad blockers kill them, browsers update, HubSpot changes their API, and you’re stuck debugging again.

Skip the browser entirely. Set up a webhook that catches HubSpot form submissions straight from their servers.

Here’s how it works: HubSpot submits form → webhook catches it → counter updates → data goes wherever you need it (database, file, whatever). You get perfect accuracy because you’re tracking actual server events instead of guessing what browsers are doing.

I use this for every client now. Takes 10 minutes to set up and you never deal with compatibility issues or missed submissions again.

Easy to expand later too - email alerts at certain counts, data exports, tracking trends over time.

Honestly, MutationObserver might be easier here. Just watch for DOM changes on the form container and check if it shows a success message or thank you text after submission. Way simpler than intercepting requests and doesn’t break if HubSpot changes their API structure.

You could hook into HubSpot’s form events to monitor submissions, but manual tracking gets messy fast. You’ll deal with failed submissions, page refreshes, browser crashes, and sync issues.

I hit this same problem tracking form engagement across multiple sites. Skip the custom tracking - set up an automation that watches HubSpot submissions and handles counting automatically.

The workflow listens for HubSpot webhook events when forms submit, then bumps a counter in your preferred storage (database, Google Sheets, local file). You get actual submission data, not just clicks that might fail.

Bonus: easily extend it later to track top-performing forms, segment by location, or get notifications at certain thresholds.

This cuts out browser complexity and gives reliable counts even with JavaScript disabled or network problems.