K
Kinde2w ago
Sara

GA4 requests blocked in custom code. Platform restriction?

I'm trying to add google analytics (GA4) tag to my custom ui using custom code, based on this template, https://github.com/kinde-starter-kits/custom-ui-splitscape. Even with the GA script added to the <head> and CSP configured, requests to https://region1.google-analytics.com are blocked in the browser with a Content Security Policy error: Refused to connect to region1.google-analytics.com... because it violates the document's Content Security Policy Could you confirm if the platform itself might be blocking external analytics scripts like GA4, or if there could be another reason for these requests being blocked? Thanks!
3 Replies
Roshan
Roshan2w ago
Hi Sara, Thanks for reaching out and sharing the details. The supported way to integrate Google Analytics is through the Kinde admin interface: 1. Go to Settings → Environment → Details in your Kinde dashboard. 2. Scroll down to the Tracking section. 3. Enter your GA4 “G-” code in the Google Analytics field and click Save. This method ensures the GA script is injected in a way that’s fully compatible with Kinde’s CSP.
Sara
SaraOP2w ago
Thank you for the quick response! Your explanation clarified the issue. I was only adding the GA4 tag in the template, assuming it didn’t need to be set in the Kinde configuration. When I switched to using custom code, the configuration no longer applied, so I thought having it in the template would be enough. I hadn’t realized it needs to be set in both places. Thanks again! 🙂
Roshan
Roshan2w ago
I'm happy to help! Please don't hesitate to reach out if you need any assistance.

Did you find this page helpful?