因为是第一次写JavaScript,所以是依照gtag和google的代码来写的,Cloudflare Web Analytics的脚本属性是defer,感觉和async有点相似所以就直接套用了。Cloudflare Web Analytics会验证主机名(hostname)与添加JS代码段的网站是否匹配。测试流程是依照hexo-theme-cards/.github/workflows/test.yml和theme-cards-demo/.github/workflows/deploy.yml来的,应该是可以使用的。
报错提示(本地报错出现这样的提示应该就是可用了):
Access to resource at 'https://cloudflareinsights.com/cdn-cgi/rum' from origin 'http://localhost:4000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://localhost' that is not equal to the supplied origin.
Cloudflare Web Analytics的JavaScript 参考片段:
<!-- Cloudflare Web Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "xxxxxxxxxx"}'></script><!-- End Cloudflare Web Analytics -->
因为是第一次写JavaScript,所以是依照gtag和google的代码来写的,Cloudflare Web Analytics的脚本属性是
defer
,感觉和async
有点相似所以就直接套用了。Cloudflare Web Analytics会验证主机名(hostname)与添加JS代码段的网站是否匹配。测试流程是依照hexo-theme-cards/.github/workflows/test.yml
和theme-cards-demo/.github/workflows/deploy.yml
来的,应该是可以使用的。报错提示(本地报错出现这样的提示应该就是可用了):
Access to resource at 'https://cloudflareinsights.com/cdn-cgi/rum' from origin 'http://localhost:4000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://localhost' that is not equal to the supplied origin.
Cloudflare Web Analytics的JavaScript 参考片段:
参考资料: