# DataFast shows nothing on localhost? That is on purpose. How to debug it anyway

> The script skips localhost, 127.0.0.1, .local hosts, iframes and browsers flagged with datafast_ignore. Turn on data-allow-localhost for a session, check the network tab, then turn it off.

You added the script, ran `next dev`, clicked around for ten minutes. DataFast
shows zero visitors. The script is fine. It is ignoring you, by design.

## What the script skips

- **Localhost.** `localhost`, `127.0.0.1`, `::1` and `*.local` hostnames. This
  keeps your dev clicks out of production numbers.
- **Iframes.** A page loaded inside an iframe is not tracked unless
  `data-debug="true"` is set.
- **Your own browser, if you asked.** `localStorage.datafast_ignore = true` in
  the console excludes that browser on that domain. Easy to forget you did it.
- **Bots.** Browsers driven by automation (`navigator.webdriver`, Selenium,
  PhantomJS) are dropped. Your Playwright suite does not pollute the numbers,
  and it cannot test tracking either.

## Turn it on, briefly

Add `data-allow-localhost="true"` to the tag. Drive it from an env var so it
can never ship to production by accident:

```tsx
<Script
  src="/js/script.js"
  data-website-id={process.env.NEXT_PUBLIC_DATAFAST_WEBSITE_ID}
  data-domain="example.com"
  data-allow-localhost={
    process.env.NEXT_PUBLIC_DATAFAST_ALLOW_LOCALHOST === "true" ? "true" : undefined
  }
  strategy="afterInteractive"
/>
```

```bash
NEXT_PUBLIC_DATAFAST_ALLOW_LOCALHOST=true
```

`NEXT_PUBLIC_` values are inlined at build time. Restart the dev server after
changing it. Set it back to `false` when you are done. Every event you send from
localhost lands in your real dashboard.

`data-domain` stays your real domain, not `localhost`.

## Walk the request

Open DevTools, Network, and reload.

1. **`script.js`, 200.** A 404 means the tag points at a path nothing serves.
   An empty 200 from your own proxy means it could not reach datafa.st: check
   the server log.
2. **Console.** The script logs why it is not tracking: "Tracking disabled on
   localhost", "inside an iframe", "bot detected". Read that before anything
   else. The `datafast_ignore` flag is quieter, so check localStorage too.
3. **`events`, a 2xx.** A POST per page view and per goal. None at all
   means the script decided not to track (step 2). A 4xx is DataFast rejecting
   the payload: usually a bad website id or a goal name with uppercase letters
   or spaces.
4. **Realtime view.** The visit appears within seconds.

## Goals that never arrive

- **Called before the script loaded, with no queue.** Without the queue stub,
  `window.datafast` is undefined for the first second of every page view. The
  call throws or does nothing. Install the stub before anything else runs:

  ```ts
  window.datafast = window.datafast || function (...args) {
    (window.datafast.q = window.datafast.q || []).push(args);
  };
  ```

- **Invalid name.** Lowercase letters, digits, `_`, `-` and `:` only, 64
  characters max. `Signup Completed` is rejected.
- **More than 10 parameters,** or a key with uppercase letters. Rejected or
  trimmed.

## Server goals from localhost

The Goals API does not care where your server runs. It cares about the visitor.
It answers `404` when the `datafast_visitor_id` has no page view on that site.
On localhost without `data-allow-localhost`, no page view was ever recorded, so
every server goal 404s. Turn the flag on, load a page, then trigger the action.

## Previews

Vercel preview URLs are not localhost, so the script tracks them. They land in
production numbers under a `*.vercel.app` hostname. Exclude that hostname in
DataFast's settings, or set the website id only in the production environment.

---

Agentic Boilerplate: A Next.js repo your agent already knows. Free during launch, then $99 once.

- Site map for agents: https://agenticboilerplate.com/llms.txt
- Public API: https://agenticboilerplate.com/openapi.json
- Contact: agenticstudio@gmail.com
