Serve the tracker from your own domain

Forward two paths on your domain to Glyphex, so blocked requests stop hiding real visits.

Why

Privacy blocklists and browser shields block some third-party analytics requests. Visitors who use them still read your pages, but their visits are not counted. When the tracker and its hits come from your own domain, your numbers stay closer to the real count.

Glyphex is cookieless and stores no personal data, so serving it from your domain does not change your consent obligations. Do Not Track and Global Privacy Control are still respected: those visitors are not counted.

The two paths

Pick a neutral path name. This guide uses /gx:

  • /gx/js forwards to https://glyphex.io/t/YOUR_SITE_ID.js
  • /gx/event forwards to https://glyphex.io/api/flow

Avoid words that blocklists look for, such as /stats, /analytics, /tracker or /collect.

Create an ingest key

Requests through your proxy come from your server, so Glyphex would see one address for every visitor: wrong visitor counts, wrong locations. The event path therefore sends the visitor's IP in a header, signed with a key for your site.

  1. In Glyphex, open your site settings, then API keys.
  2. Create a key with the Ingest agent hits scope.
  3. Store it on your server, for example as the environment variable GLYPHEX_INGEST_KEY.

Keep the key on the server. Never put it in the script tag or any code that runs in the browser.

One key carries up to 6,000 hits a minute. Above that, hits are handled as if they came without a key: they share your server's address and its rate limit, so some may not be counted.

Set up the proxy

Next.js

Rewrite the script path in next.config:

// next.config.ts (or .js)
async rewrites() {
  return [{ source: "/gx/js", destination: "https://glyphex.io/t/YOUR_SITE_ID.js" }];
},

Forward the event path from proxy.ts (Next.js 16) or middleware.ts (Next.js 15, export middleware). It adds the key and the visitor IP, and drops cookies.

// proxy.ts (Next 16) or middleware.ts (Next 15: export function middleware)
import { NextResponse, type NextRequest } from "next/server";

export function proxy(request: NextRequest) {
  if (request.nextUrl.pathname === "/gx/event") {
    const headers = new Headers(request.headers);
    // Cloudflare in front of Glyphex refuses (403) a request that carries cf-* headers.
    for (const name of Array.from(headers.keys())) if (name.startsWith("cf-")) headers.delete(name);
    headers.delete("cookie");
    headers.delete("authorization");
    headers.delete("x-glyphex-client-ip");
    // Visitor IP from the header your host sets and overwrites (never one the browser can send):
    // nginx in front (proxy_set_header X-Real-IP $remote_addr): "x-real-ip".
    // Vercel: "x-real-ip". Cloudflare straight to the app: "cf-connecting-ip".
    const ip = request.headers.get("x-real-ip");
    const key = process.env.GLYPHEX_INGEST_KEY;
    if (ip && key) {
      headers.set("authorization", `Bearer ${key}`);
      headers.set("x-glyphex-client-ip", ip);
    }
    return NextResponse.rewrite(new URL("https://glyphex.io/api/flow"), { request: { headers } });
  }
  // ...your existing proxy / middleware code
  return NextResponse.next();
}

// Add "/gx/event" to your matcher. Keep /gx/ out of locale redirects.
export const config = { matcher: ["/gx/event"] };

Read the visitor IP from a header your host sets and overwrites, never one a browser can send: x-real-ip behind nginx (proxy_set_header X-Real-IP $remote_addr) and on Vercel, cf-connecting-ip when Cloudflare talks to the app directly. If you use locale middleware, keep /gx/ out of its redirects.

nginx

Add two locations to your server block and paste your key.

location = /gx/js {
  proxy_pass https://glyphex.io/t/YOUR_SITE_ID.js;
  proxy_ssl_server_name on;
}
location = /gx/event {
  proxy_pass https://glyphex.io/api/flow;
  proxy_ssl_server_name on;
  proxy_set_header Cookie "";
  # Cloudflare in front of Glyphex refuses (403) a request that carries CF-Connecting-IP.
  proxy_set_header CF-Connecting-IP "";
  proxy_set_header Authorization "Bearer glx_YOUR_INGEST_KEY";
  # Behind Cloudflare use $http_cf_connecting_ip instead of $remote_addr.
  proxy_set_header X-Glyphex-Client-IP $remote_addr;
}

Behind Cloudflare, use $http_cf_connecting_ip instead of $remote_addr. Keep proxy_ssl_server_name on: without it the TLS handshake with glyphex.io fails.

Cloudflare Worker

Create a Worker with a route for yourdomain.com/gx/* and add the key as the secret GLYPHEX_INGEST_KEY.

// Cloudflare Worker routed at yourdomain.com/gx/*
// Secret: npx wrangler secret put GLYPHEX_INGEST_KEY
export default {
  async fetch(request, env) {
    const url = new URL(request.url);
    if (url.pathname === "/gx/js") {
      return fetch("https://glyphex.io/t/YOUR_SITE_ID.js");
    }
    if (url.pathname === "/gx/event") {
      const headers = new Headers(request.headers);
      for (const name of Array.from(headers.keys())) if (name.startsWith("cf-")) headers.delete(name);
      headers.delete("cookie");
      headers.set("authorization", `Bearer ${env.GLYPHEX_INGEST_KEY}`);
      headers.set("x-glyphex-client-ip", request.headers.get("cf-connecting-ip") ?? "");
      return fetch("https://glyphex.io/api/flow", { method: request.method, headers, body: request.body });
    }
    return new Response("Not found", { status: 404 });
  },
};

Update the script tag

Replace your current tag. src loads the tracker from your domain, data-api sends hits to your domain.

<script defer src="/gx/js" data-api="/gx/event" data-site-id="YOUR_SITE_ID"></script>

Replace YOUR_SITE_ID, in the proxy rules above and in the tag, with the ID shown in your site settings.

Verify

  1. Open your site settings in Glyphex.
  2. Go to the section Serve tracker from your domain.
  3. Enter your base URL, for example https://yourdomain.com/gx, and click Verify proxy.

The check requests /js and /event through your domain. If one fails, it tells you which rule to fix. It does not check the key: after a few visits, your locations should match your audience, not your server.