Privacy Analytics: Scripts vs SDKs vs Proxies vs APIs
Antlytics offers four ways to integrate. They all track the same data — the difference is how requests travel from your visitor's browser to the analytics backend.
The four methods
Script tag
A small inline JavaScript snippet added directly to your HTML <head>.
How it works: The script fires a fetch() request to https://www.antlytics.com/api/ingest/pageview on each page load and SPA navigation.
Best for: Any site where you can edit HTML — plain HTML, WordPress, Webflow, Squarespace, static sites.
Trade-off: Requests go to www.antlytics.com directly. Ad blockers with analytics blocklists may block them.
SDK component
An npm package (@antlytics/analytics) with a React component for Next.js.
How it works: Same mechanism as the script tag, but packaged as a React component that integrates cleanly with Next.js's <Script> API.
Best for: Next.js App Router and Pages Router projects. Handles SPA navigation automatically.
Trade-off: Adds a package dependency. Requests still go to www.antlytics.com unless combined with the proxy.
First-party proxy
A server-side route handler that forwards analytics requests from your domain to Antlytics.
How it works: The SDK sends pageview data to /api/antlytics/pageview on your domain. A thin route handler forwards it to https://www.antlytics.com/api/ingest/pageview.
Best for: Any Next.js site where accurate visitor counts matter. Ad blockers cannot block same-origin requests.
Trade-off: Requires a server-side route. Not available on fully static sites without a server.
API
Read your analytics data programmatically via the Antlytics REST API.
How it works: Bearer token authentication. Query endpoints for visitors, pages, referrers, and more.
Best for: Custom dashboards, automations, CI integrations, and AI tool integrations (MCP).
Trade-off: The API is for reading data, not writing it. You still need one of the above methods to collect pageviews.
Choosing the right method
| Situation | Recommended method |
|---|---|
| Plain HTML or CMS (WordPress, Webflow) | Script tag |
| Next.js App Router | SDK + proxy |
| Next.js (simple setup, no proxy needed) | SDK only |
| Non-Next.js framework with server-side | Script tag (or custom proxy) |
| Reading data for a custom dashboard | API |
| AI tool integration | API via MCP server |
Most developers start with the script tag or SDK, then add the proxy once they care about data completeness under ad blockers.
FAQ
Can I use multiple methods at once? Do not use the script tag and the SDK component together on the same page — you will double-count pageviews. Use one or the other.
What if I'm not using Next.js? The script tag works with any framework. For the proxy, you need a server-side endpoint — implement the forwarding logic in your framework's equivalent of a route handler.
Does the API require a subscription? API access is available on Starter. The API lets you read your data — it does not replace the need for the script tag or SDK to collect it.
Related: First-party proxy explained · Next.js setup guide · API reference