We’ve implemented Google Analytics 4 tracking using gtag() and custom event tracking (e.g., cta_click) on our HubSpot-hosted website. While the script initializes correctly, we’re seeing the following error in the browser console:
[Report Only] Refused to connect to google analytics because it violates the following Content Security Policy directive: “connect-src ‘none’”.
To ensure tracking works as expected, we need to allow these domains in the connect-src directive of our Content Security Policy:
Do anyone know how to update the CSP configuration for our domain or let us know how we can adjust this ourselves in the HubSpot settings? Using free version.
how technical are you? Do you just need page data sent to ga and not user behavior?
are you using free hubspot because you have another website built?
you could technically create a page to embed in your hubspot site and iframe it. Through this you create a proxy to GA. You have all your code to work with GA on your non hubspot site, and when you iframe it, you set up a pass through and deliver data from hubspot to the iframe - then pass that data to GA.
It’s a work around, user behavior tracking would be very different /limited - bit if you were looking for some specific data it could work
now, that being said, if you aren’t needing custom GA stuff -- are you able to use the GA integration inside settings, content, one of the tabs in there allows you to input a GA integration variable. -- that may load the script differently and work with the CSP, but that is likely a long shot on free, but worth checking imo