Skip to content

First-party proxy

Serve the script and events from your own domain to beat ad blockers.

Some blockers drop requests to third-party analytics domains. Proxy r.js and /api/e through your own domain, then point the script at it with data-api.

<script defer data-site="YOUR_PUBLIC_KEY" data-api="/rf/api/e" src="/rf/r.js"></script>

Next.js

// next.config.js
module.exports = {
  async rewrites() {
    return [
      { source: '/rf/r.js', destination: 'https://realific.app/r.js' },
      { source: '/rf/api/e', destination: 'https://realific.app/api/e' },
    ];
  },
};

Cloudflare

A Worker on your zone:

export default {
  async fetch(req) {
    const url = new URL(req.url);
    if (url.pathname === '/rf/r.js') return fetch('https://realific.app/r.js');
    if (url.pathname === '/rf/api/e') return fetch('https://realific.app/api/e', req);
    return fetch(req);
  },
};

Vercel

{
  "rewrites": [
    { "source": "/rf/r.js", "destination": "https://realific.app/r.js" },
    { "source": "/rf/api/e", "destination": "https://realific.app/api/e" }
  ]
}

Nginx

location = /rf/r.js {
  proxy_pass https://realific.app/r.js;
  proxy_set_header Host realific.app;
  proxy_ssl_server_name on;
}
location = /rf/api/e {
  proxy_pass https://realific.app/api/e;
  proxy_set_header Host realific.app;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_ssl_server_name on;
}
Forward the visitor IP (X-Forwarded-For) so geolocation and cookieless hashing stay accurate. Realific never stores raw IPs.

Custom domain

On the Growth plan you can serve the script from stats.yourdomain.com (Settings → Tracking).