Skip to main content
Sapt analytics runs first-party: the tracking script and the data it sends are served from a subdomain of your site instead of a shared third-party domain. You point one DNS record at Sapt, drop in one script tag, and your pageviews and events start flowing — measured more accurately, owned by you. Once events are flowing, the rest of this section covers what you do with them: resolve visitors to real people, read first-touch attribution, and push conversions back to ad platforms server-side.

Why first-party

Most analytics load from a shared vendor domain. Browsers and blockers treat that as third-party, so a large share of traffic never gets counted. Serving from your own domain changes that.
First-party makes analytics harder to block, not unblockable. DNS-level blockers and strict anti-CNAME modes can still opt out — which is the privacy-respecting outcome.

How it works

You add one CNAME record so a short subdomain of your site (for example m.yourdomain.com) resolves to Sapt’s ingest. Sapt issues the TLS certificate for it automatically. From then on:
  1. The browser loads the tracking script from your subdomain.
  2. The script sends each event back to that same subdomain — so the whole exchange is first-party.
  3. Sapt enriches each event (source, campaign, location, device) on the server and shows it in your analytics dashboard.

Set it up

1. Get your tracking subdomain

In the Sapt dashboard, open Analytics → Tracking and enter your site’s root domain (e.g. yourdomain.com). Sapt picks a short, neutral subdomain for you and shows the exact DNS records to add.

2. Add the DNS records

Add both records the dashboard shows you, at your DNS provider:
The CNAME routes your subdomain to Sapt. The TXT record lets Sapt issue an SSL certificate for it. Both come straight from the setup screen — copy them exactly.
Use the values shown in your dashboard. The subdomain is chosen per site, and the TXT value is one-time — don’t reuse one from another site or from this page.

3. Wait for it to go live

DNS changes take anywhere from a few minutes to a few hours. The Tracking page shows the status and a Check status button. Once it reads Active, your certificate is issued and you’re ready for the script.

4. Add the tracking script

Paste the snippet from the dashboard into your site’s <head> (it includes your assigned host and Project ID):
That’s it. The script auto-detects single-page-app route changes, so one tag covers most sites. Visit a page and you’ll see it appear in your analytics dashboard within a few seconds.

Track custom events

Once the script is loaded it exposes a small global API for events that matter to your business:
getVisitorId() returns the value of the first-party _sapt_vid cookie — a random ID with no personal data. Sending it to your backend lets you stitch anonymous visits to CRM records later. Calling identify() (or a tracked form submit) is also what moves a visitor from anonymous to identified — see Visitors & identity resolution.

Captured automatically

You don’t need to instrument these — the script records them out of the box:

Hand it to your coding agent

Let an AI coding assistant do the install. The button below copies a ready-made prompt that points your assistant at this page and keeps the setup clean — just fill in your tracking host and Project ID from the dashboard.
Setup prompt

Privacy notes

  • One first-party cookie, _sapt_vid, holds a random ID — no names, emails, or cross-site identifiers.
  • Geo and device details are derived on Sapt’s server from the request; nothing extra is collected in the browser.
  • Because there’s no third-party tracker, the script alone doesn’t require a consent banner — but follow the rules for your own region and any other tools on your site.

Keep going

Visitors & identity

Attribution analytics

Server-side conversions

Attribution MCP