You might want to route your analytics traffic through your own domain. This will lead to fewer DNS lookups as well as prevent AdBlockers from blocking it.
If you are using Next.js we recommend using the Next.js Proxy instead. We also offer an easier method for Netlify users.
✅ Your worker is now available under https://something.else.workers.dev
You can already use https://something.else.workers.dev/sb.js
as a custom domain in your script.
After deploying the worker, you need to navigate to one domain of your choice managed by Cloudflare.
/*
you want the worker to be available at. In this example we are using feedback.fish
. Our route would be: hive.feedback.fish/*
Last, we need to link the subdomain to a random IP. Navigate to DNS and create a new A record
Done! The new worker is available under hive.feedback.fish (not yours)
To use your custom domain, just replace the Splitbee script tag with:
<script async src="https://something.else.workers.dev/sb.js"></script>
In our example, feedback.fish, it would work like this:
<script async src="https://hive.feedback.fish/sb.js"></script>
In the init from our @splitbee/web library, you can provide the URL to the proxied script.
splitbee.init({scriptUrl: "https://something.else.workers.dev/sb.js"})
You can confirm by checking the DevTools network tab that all traffic indeed flows through your domain.