Proxying Proxima Analytics Script through Cloudflare Workers
If you're considering an alternative to Cloudflare Analytics, we've got you covered. Take a look at our detailed comparison against Cloudflare Analytics to find out more.
You can also check the source code for this integration here
To improve the privacy and compliance of your website, you may easily and effectively use Cloudflare Workers to proxy your Proxima analytics requests. Moreover, Cloudflare Workers is a cost-effective choice because it provides a free service for up to 100,000 requests each day. With Cloudflare Workers, setting up a proxy is simple and doesn't call for any technical expertise or prior knowledge. All you need is a Cloudflare account, which is free.
To get started, simply follow the step-by-step process outlined below. It will take only a few minutes to set up, so you can start enjoying the benefits of proxying your Analytics requests through Cloudflare Workers in no time.
- Log in to your Cloudflare account and go to the Workers section in the sidebar.
- Select Create a Service and choose Introduction (HTTP Handler) in the Select a starter section. Click Create service.
- Give your worker a meaningful name (avoiding words like "analytics", "tracking", "stats", etc.) or use the default name generated by Cloudflare.
- Paste the following code in the Quick edit section and click Save and deploy:
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
const url = new URL(request.url);
url.hostname = 'buzz.proxima.so';
const data = await fetch(url.toString(), request);
return data;
}
- Test your worker by visiting
`https://your-worker-name.dev/health`
and`https://buzz.proxima.so/health`
. If you see a JSON response with the status code 200, your worker is working properly. - Add the Proxima analytics script to your website, replacing buzz.proxima.so with the worker URL, the script will look like this:
<script
defer
src="https://your-worker-name.dev/script.js"
data-site="XXXX"></script>
You can find more information about Cloudflare Workers in the official documentation. The full source code, ready to deploy with Wrangler, is also available in our example repository.