Analytics
Fathom Analytics
Configure Fathom Analytics
Copy the site ID from your Fathom embed code, where it is the data-site
value. If your app changes routes without a full page load, also pass spa.
Without it, the helper leaves Fathom's SPA route tracking off.
Register the scripts
Complete your framework quickstart first. Keep its Inth endpoint, policy, styles and consent UI. Remove the vendor's original script, SDK initializer or tag-manager entry, so the vendor loads only through c15t.
The vendor pages put the helper in src/consent-scripts.ts. If your framework
quickstart already has a scripts array, such as the one in c15t.config.ts
in the Next.js guide, add the helper to that array instead of creating a
second file.
The scripts export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration
point for your framework below. These are edits to that provider, not a second
provider.
Add the configuration to scripts in c15t.config.ts, next to
next.config.ts:
Keep the rest of your config, such as mode and routePrefix, in the
same call. ConsentRoot reads the config in the browser, so the layout
keeps passing only state. App Router, Pages Router and static export all
read the same file. See
Next.js scripts and embeds.
Options
| Option | Default | Behavior |
|---|---|---|
site | Required | Site ID, set as data-site. The helper trims it. Empty or whitespace-only values log an error and the script does not load. |
spa | None | 'auto', 'history' or 'hash', set as data-spa. When omitted, the script has no data-spa attribute and SPA route tracking stays off. |
auto | None | Sets data-auto to 'true' or 'false' to control automatic page views. When omitted, Fathom's default applies. |
canonical | None | Sets data-canonical to control canonical URL tracking. When omitted, Fathom's default applies. |
honorDnt | None | Sets data-honor-dnt to control whether Fathom honors Do Not Track. When omitted, Fathom's default applies. |
scriptUrl | https://cdn.usefathom.com/script.js | Loader URL override. A blank value falls back to the default. |
Loading and revocation
fathomAnalytics uses the measurement category. Fathom sets no cookies, but
the helper still waits for measurement permission. It loads script.js with
defer. On revocation the helper removes the script element and calls no
Fathom API. It does not call window.fathom.blockTrackingForMe.
Verify Fathom Analytics
After you allow measurement, script.js loads from cdn.usefathom.com and its
script element carries your data-site and data-spa values. Change route in
your app and check that it sends one page view, not two. If your code calls
window.fathom?.trackEvent, check measurement permission before each call.
Test in a private window with an opt-in policy. Open DevTools Network, disable the cache and filter by the vendor's domain:
- Load the page. No request goes to the vendor before you choose.
- Click Reject, then reload. There is still no vendor request.
- Open Privacy settings and allow the helper's category. The vendor script loads without a page reload.
- Turn the category off again and save. c15t reloads the page, and the new page makes no vendor request.
c15t reloads on revocation because removing a script element does not stop
code that already ran. The vendor's listeners, timers and queued events stay
alive until the page unloads. If you set reloadOnConsentRevoked: false, stop
the vendor yourself. Register a callback-only script whose onConsentChange
calls the vendor's opt-out API, as shown in
custom integrations, and check the
permission before each of your own event calls. The reload does not delete
cookies the vendor already set; see
clear on revocation for your framework.
The helper sets vendor to its script ID, so once you declare that vendor a
visitor can turn it off inside an allowed category. See
vendor consent for your framework. The
consent verification guide covers navigation,
expiry and hosting checks.