Tracely docs
Everything you need to add Tracely to a website, track what matters, and keep it privacy-friendly.
Quick start
- Create a free account and add your site's domain.
- Copy the snippet from the install screen and paste it into the
<head>of every page:
<script defer data-site="YOUR_SITE_ID" src="https://tracely-opal-three.vercel.app/a.js"></script>
- Deploy, then open any page of your site. The install screen confirms the first visit within seconds, and the dashboard fills in from there.
Your site ID is shown in Settings → Install for each site. It is public, so it's fine in your code and repository.
Install on your framework
Plain HTML and server-rendered sites (WordPress themes, Rails, Django, Laravel, Hugo, Jekyll, Astro): put the snippet above in the shared <head> template.
Next.js (App Router), in app/layout.tsx:
import Script from "next/script";
<Script src="https://tracely-opal-three.vercel.app/a.js" data-site="YOUR_SITE_ID" strategy="afterInteractive" />
For the Pages Router, render the same <Script> in pages/_app.tsx.
Single-page apps (React, Vue, Svelte with Vite): put the HTML snippet in index.html. Page changes inside the app are tracked automatically.
Always load the script from https://tracely-opal-three.vercel.app/a.js rather than copying it, so it stays up to date.
Let your AI coding agent install it
Open your site's install screen, choose Use my AI coding agent, and paste the prompt into Claude Code, Cursor or another coding agent. The agent reads /llms.txt, follows the agent install guide, and adds the right snippet for your framework.
To let the agent confirm events are arriving, create a read-only key in Settings → API keys and give it to the agent in your terminal session. Don't let it write the key into any file.
Track signups and other actions
Page views are counted automatically. To count actions such as signups or purchases, send a custom event.
Without JavaScript, add data-track to a button or link. Extra data-track-* attributes become properties:
<button data-track="signup" data-track-plan="pro">Sign up</button>
With JavaScript:
window.track?.("signup", { plan: "pro" });
Then turn the event into a goal in Settings → Goals. Goals can also be a page, such as /thank-you. The overview then shows the conversion rate and how many visitors completed each goal, and you can build funnels from them.
Keep event names short and stable (signup, checkout:start), and never put personal data such as emails or names in events.
Automatic events
Some actions are recorded without any code:
- Downloads: clicks on file links (.pdf, .zip and similar) are recorded as
download. - Forms: submitting a form is recorded as
form, with the form's id, name or action path. Field values are never sent. - Outbound links: clicks on links to other sites are recorded (see the script options below).
- Hash routes: pages that change with a
#route are counted as separate pages only when you adddata-hashto the script. - Engaged time and scroll depth: when a visitor leaves a page, the visible time and the deepest scroll are recorded. The Pages report shows both.
To turn off downloads or forms, add data-download="false" or data-form="false" to the script.
Reports and sharing
- Overview: a plain-language summary of what changed, filters with is, is not and contains, and a trend chart. Switch the chart between visitors, pageviews, visits, bounce rate and visit duration.
- Chart notes: add a note to a date on the trend chart, for example a launch or a campaign, so you can see why a spike happened.
- Page paths: see where visitors came from before a page and where they went next.
- Retention: weekly cohorts for the last 8 weeks, showing how many visitors came back in later weeks.
- Keyboard shortcuts: press ? in the dashboard to see them.
- Glossary: the info buttons on each card explain what its numbers mean.
- Share links: in Settings → Sharing, create a read-only link to a site's dashboard. Copy it when it's created: it's shown once and works for 90 days. Rotate it for a new copy.
- Email reports: in Settings → Email reports, get a weekly digest and set up traffic alerts.
- Export: download all events as CSV.
- Stats API: read a site's stats with
GET /api/v1/sites/[siteId]/stats, using a read-only key from Settings → API keys.
Privacy and cookies
- IP addresses stay out of your reports. They are kept only in a separate security log, used to investigate attacks, for your site's retention period (24 months by default). Location comes from the request.
- Long IDs in page paths, such as UUIDs, are stored as
:id, so/orders/<id>shows as one page. Goals and funnels should match them with*, for example/orders/*. - Cookie mode (default) stores a random visitor ID in the browser, so returning visitors are recognised.
- Cookieless mode stores nothing in the browser. Visitors are counted with a hash that changes every day. Turn it on in Settings → Privacy, or add
data-mode="cookieless"to the script. The trade-offs: returning visitors count as new each day, journeys cover one day only, long-term attribution is weaker, and visitors sharing a network and browser version may be merged. - Consent mode: if your site has a cookie banner, add
data-consentto the script and callwindow.tracely?.consent()when the visitor accepts. Until then, no visitor ID is stored. - Do Not Track is respected by default. Visitors can opt out with
window.tracely?.optOut(), for example from a link on your privacy page. - Query parameters that look like secrets (
token,email,passwordand similar) are removed before anything is sent.
Cookieless mode is designed so you may not need a consent banner, but rules differ by country and site. Check what applies to your visitors; this isn't legal advice.
Serve from your own domain
Some ad blockers stop third-party analytics scripts. You can serve the script and the event endpoint from your own domain instead. In Next.js (next.config.ts):
async rewrites() {
return [
{ source: "/stats/a.js", destination: "https://tracely-opal-three.vercel.app/a.js" },
{ source: "/stats/event", destination: "https://tracely-opal-three.vercel.app/api/event" },
];
}
Then load the script with src="/stats/a.js" and data-api="/stats/event".
Know the trade-offs first: events then reach Tracely from your server, so country and city reports may show your server's location, and you must use cookie mode (in cookieless mode every visitor could be counted as one).
Troubleshooting
If the install screen keeps waiting for the first visit:
- Open the live site, not localhost. The script ignores
localhost. To test locally, addlocalhostunder Settings → General → Other hostnames and adddata-allow-localto the script in development only. - Turn off Do Not Track and ad blockers in the browser you test with.
- Check the hostname. The page must be on your site's domain, a subdomain of it, or a hostname listed in Settings → General.
- Look at the browser's Network tab for a request to
/api/event. No request means the script didn't run; a 403 response means the hostname isn't allowed; a 400 means an event name or property is too long or has unsupported characters.
Still stuck? Open Real-time in the dashboard while you load a page: a visit there confirms tracking works.
Script options
| Attribute | What it does |
|---|---|
data-site="YOUR_SITE_ID" |
Required. |
data-mode="cookieless" |
Never store an ID in the browser. |
data-consent |
Store no ID until tracely.consent() is called. |
data-outbound="false" |
Don't record clicks on links to other sites. They are recorded by default, without query strings. |
data-download="false" |
Don't record clicks on file links as download. |
data-form="false" |
Don't record form submits as form. |
data-hash |
Count hash routes (#/path) as separate pages. |
data-api="/path" |
Send events to this URL (for serving from your own domain). |
data-dnt="false" |
Ignore the browser's Do Not Track setting. |
data-allow-local |
Track on localhost. For local testing only. |