Load Cloudflare Web Analytics beacon on cookie accept with tunnel token

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-20 16:04:21 +01:00
parent 8cdd825e32
commit fb5073908e

View File

@@ -25,6 +25,20 @@ function loadAnalytics() {
script.dataset.hostUrl = '/stats'
script.dataset.analytics = '1'
document.head.appendChild(script)
loadCloudflareTunnel()
}
function loadCloudflareTunnel() {
if (document.querySelector('script[data-cf-beacon]')) {
return
}
const script = document.createElement('script')
script.defer = true
script.src = 'https://static.cloudflareinsights.com/beacon.min.js'
script.dataset.cfBeacon = '{"token":"5f2f3b8e1f824be6984a348fe31d2f04"}'
document.head.appendChild(script)
}
export function initCookieConsent() {