Install guides

Serve PageLens from your own domain

Ad blockers often drop requests to third-party analytics domains, which can hide 10–30% of visits on tech audiences. A first-party proxy forwards /pl/* on your domain to PageLens, so the browser only talks to your site.

1. Add a proxy rule

Next.js · next.config.js

module.exports = {
  async rewrites() {
    return [{ source: '/pl/:path*', destination: 'https://app.pagelens.io/:path*' }];
  },
};

Cloudflare Worker · Route: example.com/pl/*

export default {
  async fetch(request) {
    const url = new URL(request.url);
    const target = 'https://app.pagelens.io' + url.pathname.replace(/^\/pl/, '') + url.search;
    const headers = new Headers(request.headers);
    headers.set('X-Forwarded-For', request.headers.get('CF-Connecting-IP') || '');
    headers.delete('cookie');
    return fetch(target, { method: request.method, headers, body: request.body });
  },
};

Vercel · vercel.json

{
  "rewrites": [
    { "source": "/pl/:path*", "destination": "https://app.pagelens.io/:path*" }
  ]
}

Netlify · public/_redirects

/pl/*  https://app.pagelens.io/:splat  200

Nginx · server block

location /pl/ {
    proxy_pass https://app.pagelens.io/;
    proxy_set_header Host app.pagelens.io;
    proxy_ssl_server_name on;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Cookie "";
}

Caddy · Caddyfile

handle_path /pl/* {
    reverse_proxy https://app.pagelens.io {
        header_up Host app.pagelens.io
        header_up X-Forwarded-For {remote_host}
    }
}

2. Load the script through it

<script defer src="/pl/script.js" data-site-id="YOUR_SITE_ID"></script>

The script loads everything else (event tracking, session replay, settings) from next to itself, so all requests go through /pl/. Forward the visitor's IP in X-Forwarded-For as shown. It's used only to look up the country and is never stored.

Don't have a site ID yet?

Create a free PageLens account: 7-day trial, no card, no cookie banner needed.

Start free trial