How to prevent Cloudflare from auto-inserting any JS code on my website?

I have setup a static website with Cloudflare Pages, and enabled Web Analytics for it. I thought that inserting the Cloudflare Web Analytics JS Snippet is optional, but I see that it is being automatically inserted by Cloudflare, is there anyway to prevent Cloudflare from auto-inserting any JS code on my website?

You can disable the automatic JS snippet injection from within the Web Analytics section of the dashboard.

  • Head to the Web Analytics section of the dashboard
  • Find your website and hit “Manage site”
  • Toggle open the “Advanced Options”
  • Toggle “Disable automatic setup”
  • Hit “Update”
3 Likes

Hi @cherryjimbo , thank you for your reply.

When I go to Web Analytics then Manage site, I don’t see anything that says “Advanced Options”, I do have a free account and I am not using Cloudflare’s hostname, maybe that’s why?

Sorry, a made a typo, I meant to say…

…I do have a free account and I am using Cloudflare’s hostname…

If you are using Pages and enabled Web Analytics from Pages settings, the beacon script will be bundled with your source.

You do not see “Advanced Options” when you go to Web Analytics > Manage site, because Web Analytics is enabled through the Pages project.

If you want to disable Web Analytics for your Pages project, simply go to Pages settings and disable Web Analytics from there. You would need to build again to get the updated source.

3 Likes