Google Analytics has been deemed illegal by the EU DPA. Undicat is a British company, operated fully on European infrastructure.

Next.js Proxy

You can use Next.js (version 9.5+) to route all analytics traffic through your own server and domain. This will reduce DNS lookups, as well as prevent Adblockers from blocking requests.

1. Add rewrites to next.config.js

Add following rewrite rules into the file:

module.exports = {
  async rewrites() {
    return [
	      source: "/analytics.js",
	      destination: "",
	      source: "/_catnip/:slug",
	      destination: "",

Find the Next.js documentation here

2. Adapt the analytics config

You will need to adapt the script tag to reflect the changes and use your own proxy.

Using in html

<script async endpoint="/_catnip" src="/analytics.js"></script>

endpoint sets the endpoint for all tracking calls. We are using /_catnip in this example but feel free to use whatever you would like.

Using the JavaScript Library

When using the @undicat/analytics library, you can provide the custom endpoint and the URL to the proxied script in the init function.

undicat.init('ABCDEFGHI', {
  endpoint: "/_catnip",

All set. You can check the network tab inside DevTools to verify that all traffic indeed passes through your domain.