Free-first Cloudflare Worker for the blog visitor stats sidebar.
Set these in the Worker dashboard under Settings > Variables.
Variables:
GA_PROPERTY_ID: 470889906GA_CLIENT_EMAIL: hyuk-blog-ga-stats@hyuk-blog-ga-stats.iam.gserviceaccount.comALLOWED_ORIGIN: https://hyuk.blogCACHE_TTL_SECONDS: 60GA_TOTAL_START_DATE: optional, defaults to 2020-01-01Secret:
GA_PRIVATE_KEY: the full private_key value from the downloaded service account JSONDo not commit the service account JSON file or paste the private key into source files.
Create a Worker named hyuk-blog-ga-stats in the Cloudflare dashboard and paste
ga-stats-worker.js into the Worker editor.
After deployment, set _config.yml:
visitor_stats:
endpoint : "https://hyuk-blog-ga-stats.YOUR_SUBDOMAIN.workers.dev"
refresh_seconds : 60
The blog expects:
{
"status": "ok",
"metrics": {
"realtimeActiveUsers": 0,
"todayActiveUsers": 0,
"monthActiveUsers": 0,
"totalActiveUsers": 0
}
}