Enable Web Analytics Though Api

Hello,

I am trying to replicate what we can do though the web interface at the following location:
Cloudflare → Analytics → Web Analytics → Set up hostname → Enter your website’s hostname or select from your existing websites on Cloudflare.

How can we activate analytics and enter the website hostname though the api?

Mike

I’d like to do the same, is there a way API to access web analytics for a website not proxied through Cloudflare?

POST /api/v4/accounts/:account_id/rum/site_info might work - with a request body like {"host":"example.com"}.

It’ll return a snippet for you to use.

{
  "result": {
    "site_tag": "<snip>",
    "site_token": "<snip>",
    "host": "example.com",
    "created": "2022-06-12T17:34:08.305308Z",
    "snippet": "\u003c!-- Cloudflare Web Analytics --\u003e\u003cscript defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{\"token\": \"<snip>\"}'\u003e\u003c/script\u003e\u003c!-- End Cloudflare Web Analytics --\u003e",
    "auto_install": false
  },
  "success": true,
  "errors": [],
  "messages": []
}

I don’t actually know if this is available on the public API (https://api.cloudflare.com/client/v4/)