First-party proxy (optional)
Some ad blockers filter third-party analytics domains. A first-party proxy forwards browser ingest through your origin so requests look like ordinary same-site traffic.
1. Install the package
npm install @antlytics/analytics
# or
pnpm add @antlytics/analytics
2. Mirror ingest routes on your site
Prefer the same paths the tracker already uses so apiHost is just your origin:
// app/api/ingest/pageview/route.ts
export { GET, OPTIONS, POST } from "@antlytics/analytics/proxy"
// app/api/ingest/event/route.ts
import { event } from "@antlytics/analytics/proxy"
export const { GET, OPTIONS, POST } = event
// app/api/ingest/engagement/route.ts
import { engagement } from "@antlytics/analytics/proxy"
export const { GET, OPTIONS, POST } = engagement
Legacy pageview-only proxy still works:
// app/api/antlytics/pageview/route.ts
export { GET, OPTIONS, POST } from "@antlytics/analytics/proxy"
3. Point the tracker at your domain
import { Analytics } from "@antlytics/analytics/next"
<Analytics
trackingId="YOUR_TRACKING_ID"
apiHost="https://your-domain.com"
/>
Or with the hosted script tag, set data-api-host to your origin.
Each handler forwards to Antlytics /api/ingest/{pageview,event,engagement} with the browser User-Agent and client IP (X-Antlytics-Client-Ip) so datacentre filtering, rate limits, and country enrichment see the visitor — not your server’s egress IP. Use @antlytics/analytics 0.1.6+ for event + engagement proxy helpers. If you roll your own proxy, send the same headers (see proxy setup in the repo).
Something missing? Get in touch and we will update these docs.