Skip to the page

Developer GuidePrivacy and delivery

First-party proxy

Serve the Venbit tracker from your own domain so ad blockers let it through. Tested configs for nginx, Apache, Vercel, Netlify, Next.js and Cloudflare.


A first-party proxy forwards one folder of your own domain to Venbit. The tracker then loads from yoursite.com/vb/m.js and reports to yoursite.com/vb/api/e, and an ad blocker that stops requests to Venbit's hosts lets those through, so the visitors it was hiding get counted. You need one forwarding rule on your server and a different install line.

A proxied site uses this install line:

HTML
<script defer src="/vb/m.js" data-site="KEY" data-endpoint="/vb/api/e"></script>
With the proxy, the browser only ever talks to your own domain

It's optional. The dashboard has the same steps under Settings, Tracking, Ad blockers, with your key and domain filled in.

What you give up

Read this before you set it up.

  • Location shows your server, not the visitor. Venbit reads a visitor's country and city from the address a visit arrives from, and through the proxy that address is your server's. No header passes the visitor's address on, so adding X-Forwarded-For or similar rules won't help. The visitor map and every location figure will show where your server is.
  • Visits can be hidden as likely bots. Traffic arriving from a hosting provider's network can be treated as automated. With your server in a large data center, proxied visits may get filtered out of your numbers, which defeats the purpose. Check your counts after switching.
  • You own a piece of config. Lose the forwarding rule in a server move or a redesign and the tracker stops loading. Counting stops too, with no error on the page.

In practice the proxy pays off when the visit count matters more to you than the map.

1. Forward /vb/ to venbit.com

Add one rule on the server or host that runs your site. Pick yours below. These are the same configs the dashboard hands out.

nginx

nginx
location /vb/ {
  proxy_pass https://venbit.com/;
  proxy_ssl_server_name on;
}

Put it inside the server block for your domain, then reload nginx. You need proxy_ssl_server_name on, because without it the connection to venbit.com fails.

Apache

Apache
SSLProxyEngine on
ProxyPass "/vb/" "https://venbit.com/"
ProxyPassReverse "/vb/" "https://venbit.com/"

This goes inside the VirtualHost for your domain, with mod_proxy, mod_proxy_http and mod_ssl turned on. Restart Apache afterwards.

Vercel

JSON
{
  "rewrites": [
    { "source": "/vb/:path*", "destination": "https://venbit.com/:path*" }
  ]
}

Add it to vercel.json at the root of the project. If you already have rewrites, append this one to the list, then redeploy.

Netlify

/vb/*  https://venbit.com/:splat  200

It belongs in the _redirects file of your publish folder, above any rule that starts with /*. Then redeploy.

Next.js

JavaScript
async rewrites() {
  return [
    { source: "/vb/:path*", destination: "https://venbit.com/:path*" },
  ];
},

Put it inside the config object in next.config.js (or .mjs or .ts), next to what's already there, and redeploy.

Cloudflare

JavaScript
export default {
  fetch(request) {
    const url = new URL(request.url);
    url.hostname = "venbit.com";
    url.pathname = url.pathname.slice(3);
    return fetch(new Request(url, request));
  },
};

Create a Worker with this code and give it the route harborroofing.example/vb/*, plus www.harborroofing.example/vb/* if the site answers on www. Your domain's DNS has to run through Cloudflare's proxy (the orange cloud).

slice(3) strips /vb from the front of the path. Using a folder with another name? Change the number to match its length, slash included.

2. Swap the install line

Replace the install line on every page with the proxied one.

HTML
<script defer src="/vb/m.js" data-site="KEY" data-endpoint="/vb/api/e"></script>

Compared with the standard line, two things changed:

  • src points at your own folder, so the tracker file now comes through your server.
  • data-endpoint tells the tracker where to send visits. Leave it off and a tracker loaded from your domain still reports straight to Venbit, where the blocker stops those requests.

Both values are paths rather than full addresses, so the line works with and without www. Keep one install line per page: remove the old one instead of adding this beside it.

A coding agent can make both changes (the forwarding rule and the new line):

Set up a Venbit first-party proxy in this project. Forward /vb/ to https://venbit.com/: in Next.js add { source: "/vb/:path*", destination: "https://venbit.com/:path*" } to rewrites in next.config; in vercel.json add the same rewrite; in nginx use proxy_pass https://venbit.com/ with proxy_ssl_server_name on. Replace the Venbit tag on every page with <script defer src="/vb/m.js" data-site="KEY" data-endpoint="/vb/api/e"></script>, KEY = [your site key], and remove the old vnbt.app line.

Set the endpoint without the attribute

Google Tag Manager and some optimisation plugins rebuild script tags and drop data- attributes. If you're using one of those, set the endpoint as a global before the tracker loads and carry the key in the address:

HTML
<script>window.venbitEndpoint = "/vb/api/e";</script>
<script defer src="/vb/m.js?s=KEY"></script>

window.venbitEndpoint stands in for data-endpoint, and ?s=KEY stands in for data-site. When both the attribute and the global are present, the attribute wins.

3. Check it works

  1. Open https://harborroofing.example/vb/m.js in a browser, using your own domain. You should see the tracker's code. An error page or your site's 404 means the forwarding rule isn't in effect.
  2. Turn your ad blocker on and open your site in a private window.
  3. Open the Network tab of the developer tools and filter for vb. You should see m.js load and, a few seconds later, a POST to /vb/api/e that succeeds.
  4. Reload the Venbit dashboard. The website switcher shows 1 live beside your site.

Step 1 works but step 4 doesn't? Make sure the install line on the page is the proxied one, and that an old line isn't still there.

What else goes through the proxy

That single rule covers everything the tracker asks for: the script (/vb/m.js), the visits (/vb/api/e), the settings request and form protection. You don't need a rule for each.

The Site Agent is left out. When it's switched on, it still loads from https://venbit.com, and a blocker that stops Venbit's hosts will hide it.

If your site sets a Content Security Policy, a proxied install only needs 'self'. See Content Security Policy.

Use a different folder name

The dashboard uses /vb/, but any folder works as long as the forwarding rule, the src and the data-endpoint all agree. For a folder called /stats/:

HTML
<script defer src="/stats/m.js" data-site="KEY" data-endpoint="/stats/api/e"></script>

Keep /api/e as the last part. The tracker works out its other addresses from it.

Common questions

Does a first-party proxy get Venbit past ad blockers?

Yes, for blockers that stop requests to Venbit's own hosts. Through the proxy the tracker loads from yoursite.com/vb/m.js and reports to yoursite.com/vb/api/e, so those visitors get counted.

Why does my Venbit visitor map show my server's location?

Venbit reads location from the address a visit arrives from, and through a proxy that's your server's address. No header passes the visitor's address on, so every location figure shows where your server is.

Does the Venbit Site Agent work through the proxy?

The proxy doesn't cover it. With the Site Agent switched on, it still loads from https://venbit.com, and a blocker that stops Venbit's hosts hides it.

How do I check that my Venbit proxy works?

Open https://yourdomain/vb/m.js and you should see the tracker's code. An error page there means the rule isn't working. Then, with an ad blocker on, filter the Network tab for vb and look for a successful POST to /vb/api/e.

Last updated . Something wrong or missing on this page? Tell us from Settings, then Support.