analytica.click
Connect a site
Follow these steps once per website. Domain ownership must be verified before keys are issued or normal analytics is collected.
1. Add the site
Sign in, open Settings and choose Add site. Enter the bare hostname, for example example.com. The number of sites you can add depends on your plan. For a service with no website, choose Backend project instead: it skips the next step and gets only an admin key.
2. Verify domain ownership
Settings shows a CNAME record for the site: the name is _analytica. and the target is .ownership.analytica.click. The target is derived from the domain, so it stays the same if you remove and re-add the site. If the domain is on Cloudflare, choose Authorize DNS setup to add the record automatically; otherwise add it at your DNS provider. Then choose Recheck. Ownership is rechecked daily. If a previously verified site becomes unverified, existing keys can send only build and custom-event diagnostic receipts, shown in the ownership notice and excluded from analytics. Each receipt contains the event name, optional build ID, receive time and key type; it contains no event properties or visitor details and is kept for up to 120 days. Receipts are not backfilled after verification returns.
3. Generate API keys
After ownership verification succeeds, generate a public client API key (akpub\...) for browser tracking and an admin API key (akadmin\...) for servers, build pipelines and the data API. New sites do not receive keys before verification. The public client key stays visible in Settings and is safe to include in browser code. Admin keys are private, but like the client key they stay visible to you in Settings; they are stored encrypted. Keys issued before this change show only a hint; after verification, rotate one to make the replacement key available in Settings.
4. Install the SDK
Install analytica.click and wrap your app in AnalyticaClickProvider with the client API key, as shown below. Browser event origins are checked against your site domain and its subdomains.
5. Proxy the collector (recommended)
Serve /ac from your own domain with the Cloudflare Worker or Next.js helper below. Visitors never contact analytica.click directly, and events are tagged with country and region. Visitor IP addresses are not stored in your analytics data.
Installation
npm install -S analytica.click
How to use
Wrap your top level component with the AnalyticaClickProvider
import { AnalyticaClickProvider } from 'analytica.click';
<AnalyticaClickProvider values={{ analyticaToken: 'your api token' }}>
<YourApp />
</AnalyticaClickProvider>
Automatic page tracking
By default, the provider records the initial visit and pathname changes, including back and forward navigation. Query and anchor changes do not create extra page views.
Optional manual page tracking
Set autoTrackPageViews to false in the provider values to control page views yourself. Call page() when a visit should be recorded. Custom events remain independent of page tracking.
import { useAnalytica } from 'analytica.click';
const { page } = useAnalytica();
// Inside your navigation handler, with automatic tracking disabled:
page();
Example of event tracking
import { useAnalytica } from 'analytica.click';
const { event } = useAnalytica();
event({
eventName: 'acme/acme.com/signup/complete',
properties: { plan: 'pro', seats: 3 },
});
Event names
Scope every event name with slashes as account/site/feature/usage, such as acme/acme.com/hotlink/hover/location. Use your account name, then the site domain, then the feature and what the visitor did with it, adding a segment for each detail you want to compare. Keep each segment lowercase and short, and put variable details such as ids in the last segments or in the properties. The dashboard stores the name exactly as sent.
Event property limits
Event properties can be strings, finite numbers other than negative zero, booleans, or null. Each event accepts up to 20 properties; property names can be up to 64 characters and string values up to 256 characters. Invalid properties reject the whole event. Every non-empty property map, including its names, is encrypted at rest.
Event values
An event can carry an optional number, such as a duration or an amount. The dashboard then offers Sum and Average beside Count. Events that share everything but their last segment, such as acme/acme.com/save-load/new and acme/acme.com/save-load/old, form a group: click the group in the Events widget to compare its events with each other and with the previous period. Every event counts toward the monthly event limit, with a value or without.
import { useAnalytica } from 'analytica.click';
const { event } = useAnalytica();
// Compared with each other in the group acme/acme.com/save-load.
event({ eventName: 'acme/acme.com/save-load/new', value: 840 });
event({ eventName: 'acme/acme.com/save-load/old', value: 1260 });
Widgets that report under their own site
Every event and page view is recorded against the address of the page it was sent from, which in a widget embedded in another site is that site’s full URL, including its path, query and hash. A widget that reports under its own analytica site can set the optional pageLocation on event() and page() to record that address instead, for example the widget’s own address. An empty value is ignored and the page address is used.
const { event } = useAnalytica();
event({
eventName: 'acme/widget.example/widget/open',
pageLocation: 'https://widget.example/embed',
});
Example of integrating analytica.click with your github build pipeline
- name: notify analytica of build
if: always()
uses: andreigecanalytica/analytica.click.gh@v2
with:
ANALYTICA_TOKEN: '${{ secrets.ANALYTICA_TOKEN }}'
Set the token to your project Admin Api Key. Server-side requests authenticated with the Admin Api Key bypass bot filtering; the regular Api Key is treated as client traffic and can be dropped as a bot.
Proxy the collector through your own domain
Serve the tracking endpoint from your own domain so visitors never contact analytica.click directly, and so each event is tagged with the visitor country and region. Requests to /ac/* are forwarded to https://api.analytica.click/*. Only the content-type, user-agent and origin headers and the geo headers are forwarded, and your site cookies and authorization header never leave your domain. Point the provider at the proxy with overrideBaseUrl.
<AnalyticaClickProvider
values={{ analyticaToken: 'your api token', overrideBaseUrl: '/ac' }}
>
<YourApp />
</AnalyticaClickProvider>
Cloudflare Worker
Import analyticaWorkerRoute from analytica.click/proxy/worker. It returns the proxied response for /ac/* and null for every other path. The proxy reads the country and region from request.cf, forwards the request and strips Set-Cookie from the response.
import { analyticaWorkerRoute } from 'analytica.click/proxy/worker';
export default {
async fetch(request: Request): Promise<Response> {
return (
analyticaWorkerRoute(request) ?? new Response('Not found', { status: 404 }) // or your own handler
);
},
};
Next.js middleware
Import analyticaNextProxy from analytica.click/proxy/next and match /ac/:path* (exported as analyticaProxyMatcher; Next only accepts a literal matcher). The helper takes the country and region from @vercel/functions and rewrites /ac/* to the collector. Install next and @vercel/functions in your project; both are optional peer dependencies. Next cannot remove Set-Cookie from a rewritten response, which is safe because the collector never sets cookies.
// proxy.ts on Next 16 (on older versions: middleware.ts exporting middleware)
import { analyticaNextProxy } from 'analytica.click/proxy/next';
import type { NextRequest } from 'next/server';
// Next reads the matcher at build time, so it must be a literal. It equals analyticaProxyMatcher.
export const config = { matcher: ['/ac/:path*'] };
export const proxy = (request: NextRequest) => analyticaNextProxy(request);
Identify the visitor
A visitor has one identity, browserFingerprint. Leave it out and the collector derives one from the request headers. A site with its own sign-in can set it to the signed-in visitor’s email address. A site with a server can compute one during the server render with generateBrowserFingerprint(headers) and pass it to the provider, which is also what lets feature() give the server and the browser the same answer. It is encrypted before it is stored, and an email sent here is matched against your tracking exclusions like any other fingerprint. Set it once on the provider, or override it per call on event(), page() and presence(), and set it back to undefined on sign-out. Never put it in the event name. Changing it changes the visitor: someone who signs in counts as a new visitor from then on, and in an experiment may land in the other variant.
<AnalyticaClickProvider
values={{ analyticaToken: 'your api token', browserFingerprint: 'customer@example.com' }}
>
<YourApp />
</AnalyticaClickProvider>
Breaking change: earlier versions took a separate customer identity value and a nested fingerprint override. Both are removed, and the stored customer identity values are deleted. Set browserFingerprint at the top level of the provider values, or on a call, instead.
Feature flags and experiments
Call feature(code, defaultValue) from useAnalytica() to ask whether a feature is on for this visitor. It returns a boolean: the default, unless a running experiment sets that code. Create experiments in the dashboard’s Experiments card, under Last Month, which lists every code your pages have asked for. An experiment has a control, variant a, and one to three more variants, b to d. Each variant after the control takes the share of visitors you set, and the control keeps the rest, 50/50 by default. Each variant sets its codes to true or false. The variant is chosen on your site from a hash of the visitor’s browserFingerprint, so a visitor keeps their variant, and no cookie or browser storage is used. The call is synchronous, so it is safe to make while rendering. It returns the default when there is no running experiment for the code, no config yet or no browserFingerprint. When you pass no experimentConfig, the provider fetches the config in the browser by the site’s own domain, so the browser needs no key for it. That works only for a verified project, and not on localhost or an IP address, where there is no config and every call returns its default.
import { useAnalytica } from 'analytica.click';
const { feature } = useAnalytica();
const blueButton = feature('pricing-button-blue', false);
A feature code is lowercase letters and digits separated by single hyphens, at most 64 characters, such as pricing-button-blue. A code can be set by only one running experiment of a site at a time. Flags are boolean only.
Match the server render
To render the same value on the server and in the browser, compute the browserFingerprint from the request headers and fetch the experiment config on the server, then pass both to the provider. generateBrowserFingerprint(headers) takes a Headers object or a plain record and returns a string, or undefined when the headers hold nothing to hash. createFeature({ analyticaToken, browserFingerprint }) returns a synchronous feature(code, defaultValue) for that visitor, and getExperimentConfig({ analyticaToken }) returns the config it uses. Both read one public JSON file per site, cached for about 5 minutes in the server process, and never throw: when the fetch fails there are no experiments for a minute and every call returns its default. Servers read the config by the site’s public client key, so use that key as analyticaToken: it is served only for client keys, never for admin keys. Browsers read the same config by the site’s domain instead, which is what the provider does when it is not given experimentConfig, and getExperimentConfig({ domain }) does it by hand. The config is public JSON that anyone can request, so keep nothing secret in an experiment id, a feature code or a goal event, and it is served only for a verified project. A site with a Content-Security-Policy must allow https://data.analytica.click and https://api.analytica.click in connect-src, or the browser cannot read the config and every call returns its default. Server calls report nothing: the browser reports the codes it evaluates when the page hydrates.
import { headers } from 'next/headers';
import {
AnalyticaClickProvider,
createFeature,
generateBrowserFingerprint,
getExperimentConfig,
} from 'analytica.click';
const analyticaToken = 'your public client key';
export default async function Layout({ children }: { children: React.ReactNode }) {
const browserFingerprint = generateBrowserFingerprint(await headers());
const experimentConfig = await getExperimentConfig({ analyticaToken });
const feature = await createFeature({ analyticaToken, browserFingerprint });
const blueButton = feature('pricing-button-blue', false); // use it while rendering
return (
<AnalyticaClickProvider values={{ analyticaToken, browserFingerprint, experimentConfig }}>
{children}
</AnalyticaClickProvider>
);
}
Count conversions with a goal event
An experiment can name a goal event. When a visitor who is in the experiment sends that event with event(), the Experiments card counts a conversion for their variant and shows each variant’s exposures, conversions, conversion rate and its difference from the control for the last 30 days. Editing an experiment or starting a stopped one deletes its exposures and conversions and counts again from zero. Name the goal event the way you name every event, as account/site/feature/usage. Each page view reports the codes it asked for in one request. These reports do not count against your monthly event limit.
Limits
Config changes reach your site within about 5 minutes, so stopping an experiment is not instant. A visitor keeps their variant only while their browserFingerprint stays the same: a browser update can change a fingerprint computed from headers and move the visitor to the other variant, and visitors with identical devices, browsers and languages share one. Rates are per page-view exposure, not per unique visitor, and the card shows no significance test.
Identify your own mobile app
If your site is also shown in a WebView inside your own installed mobile app, set the optional app value so those visits can be told apart from browser visits. Your site's code builds the string itself, for example from the token your app adds to its user agent: the platform name ending in app, then optionally a slash and the version, then optionally the build in brackets. androidapp/1.0.0 (8), iosapp/1.0.0 and androidapp are all valid. The platform is lowercase letters, digits and hyphens, the version is up to 30 letters, digits and . + - characters, the build is up to 9 digits, and the whole value is at most 64 characters. A value in any other format is ignored and the visit is still recorded. Leave app empty for normal browser traffic. Only your own app is identified: in-app browsers of other apps, such as Instagram's, are not, and stay in the browser rows. Set it once on the provider, or override it per call on event() and page(). The browser script has no app option. Agents can find sessions from an app with the apps filter of the MCP find_sessions tool.
<AnalyticaClickProvider
values={{ analyticaToken: 'your api token', app: 'androidapp/1.0.0 (8)' }}
>
<YourApp />
</AnalyticaClickProvider>
MCP server
AI agents query the data through the MCP server. Its usage is documented at https://analytica.click/llms.txt.