Skip to main content
A first-party proxy is a small piece of code on your own server. It serves the tracker from your domain and forwards its events to OpenRevenue: Every other path under /or/ returns 404.

Why use it

  • Ad blockers. Many blocklists match requests to analytics domains. Requests to your own domain at /or/ are not on those lists, so fewer pageviews go missing.
  • Correct visitor location. Without a key, OpenRevenue would see your server’s address instead of your visitor’s. The proxy sends a key, the visitor’s address and, where your platform provides it, the visitor’s location. OpenRevenue uses them only when the key is valid for the project.
The proxy does not change how long OpenRevenue recognises a returning visitor. The tracker stores its visitor ID in the browser exactly as it does without a proxy.

How it works

  1. The browser loads /or/s.js from your site. Your proxy fetches it from OpenRevenue.
  2. The tracker sees that it was loaded from /or/s.js and sends events to /or/e next to it, on your domain.
  3. Your proxy forwards each event to OpenRevenue with your proxy key and the visitor’s address and location.
  4. OpenRevenue checks the key. If it’s valid for the project, it records the forwarded address and location. If it isn’t, the event is still counted, but without the visitor’s address and location. All visitors then share your server’s address, so on a busy site per-address rate limits can start dropping events: keep the key valid.

Set it up

1

Create a proxy key

Open Settings → Proxy for your project and click Create proxy key. Copy the key: it starts with orpx_ and is shown only once. OpenRevenue stores only a hash of it.Only project owners and admins can create, rotate or remove keys.
2

Add the proxy to your site

Pick the recipe for your platform below and paste it as-is. Store the key on the server only. It must never appear in your HTML or JavaScript.
3

Change the script tag

Load the tracker from your own domain:
Replace your-project-id with the project ID from Settings → General. You don’t need any other attribute: events go to /or/e automatically.
4

Check the setup

In Settings → Proxy, under Check proxy, enter your proxy address (for example https://example.com/or) and click Check. OpenRevenue loads /or/s.js and calls /or/check through your proxy, then shows whether the key is valid and whether the visitor’s address and location arrive. No event is recorded. See Check the proxy.

Recipes

Each recipe is one file with no dependencies. They forward only the browser headers OpenRevenue needs (see What the proxy forwards).
For the App Router in Next.js 15 and 16, on Vercel or any other host. Save the file as app/or/[...path]/route.ts (or src/app/or/[...path]/route.ts if you use a src folder).Set OPENREVENUE_PROXY_KEY in your server environment, for example in your Vercel project settings. Don’t prefix it with NEXT_PUBLIC_: that would publish it in your JavaScript.
app/or/[...path]/route.ts
  • Visitor address: the first entry of x-forwarded-for, or x-real-ip, as your host sets them.
  • Location: on Vercel, from Vercel’s x-vercel-ip-* headers. On other hosts, events are recorded without a location.
  • Caching: the script is cached for an hour. Events and checks are never cached.
  • Self-hosted OpenRevenue: set OPENREVENUE_COLLECTOR_ORIGIN to your OpenRevenue address.

Check the proxy

Check proxy in Settings → Proxy runs this check for you. You can also call it yourself:
A working proxy returns:
If key is invalid, check that the environment variable or placeholder holds the full key and that you redeployed after changing it.

Rotate or remove the key

  • Rotate: Settings → Proxy → Rotate key creates a new key. The old key keeps working for 24 hours, so you have time to deploy the new one.
  • Rotate and revoke: the old key stops working immediately. Use this if the key leaked.
  • Remove: every key for the project stops working.
While a proxy sends a key that isn’t valid, its events are still counted, but OpenRevenue ignores the forwarded address and location: it sees your server’s address and records no location.

What the proxy forwards

To OpenRevenue, the proxy sends:
  • The event body, unchanged.
  • These browser headers, unchanged: Content-Type, User-Agent, Accept-Language, Origin, Referer, Sec-Fetch-Site, Sec-Fetch-Mode, Sec-Fetch-Dest and Sec-GPC.
  • Your proxy key, the visitor’s address, the visitor’s location if your platform knows it, and the recipe name.
It never sends cookies, Authorization headers or any other request header. Back to the browser, the proxy returns only the status, the body, Content-Type and Cache-Control. It never passes on Set-Cookie.

Limits

  • Without a valid key, OpenRevenue can’t trust the forwarded address, so it records your server’s address and no location.
  • nginx without Cloudflare in front, and Next.js outside Vercel, can’t send a location. Events are counted without one.
  • The proxy must be on the same site as your pages. OpenRevenue still checks the Origin of each event against your project’s allowed hostnames.
  • If you use a different path than /or/, change it in the recipe and in the script src. The tracker always sends events to e next to the script, for example /stats/e for /stats/s.js. To send events somewhere else, set data-api on the script tag to the full event URL.