I’m trying to add HubSpot tracking functionality to my Chrome extension but running into issues with URL protocols. The extension uses chrome:// protocol which conflicts with the tracking script expectations.
What I’ve tried:
- Modified the script source to use HTTPS protocol directly
- Added the required domains to my manifest.json permissions
The Problem:
When the HubSpot script executes, it attempts to load additional resources using relative URLs. These get resolved as chrome://track.hubspot.com instead of the proper HTTPS URLs, causing the requests to fail.
My Question:
Is there a way to make the HubSpot analytics script work properly in a Chrome extension environment without having to manually download and modify the script files? Any configuration options or workarounds that could help resolve this protocol mismatch?
Had the same problem with Google Analytics in my extension last year. The protocol mismatch is annoying as hell. I fixed it by creating a background script that handles all tracking calls through fetch() requests straight to HubSpot’s API endpoints. Instead of letting their script load extra resources, I intercepted the data collection and sent it manually with proper HTTPS URLs. You’ll need to check their network requests to see what data they want, but it’s way more reliable than dealing with protocol issues. Also don’t forget to add HubSpot domains to your host_permissions if you’re using Manifest V3.
Same headache here with Mixpanel in my extension. Try setting document.baseURI or switch to a content script instead of injecting straight into extension pages. The chrome:// protocol is annoying but running analytics from content scripts usually works since they execute in the webpage’s context.
This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.