Localhost tracking

How Rybbit handles traffic from localhost during development

Rybbit does not restrict tracking to your registered domain — the tracking script works from localhost (or any other origin) out of the box. As long as your snippet carries a valid site ID, events sent during local development are recorded like any other traffic.

<script src="https://app.rybbit.io/api/script.js?siteId=YOUR_SITE_ID" defer></script>

Older snippets that pass the ID as data-site-id still work.

Because localhost traffic is tracked by default, the usual problem is the opposite one: development visits polluting your production analytics. Use one of the approaches below to keep your data clean.

Keeping development traffic out of production data

Option 1: Use a separate development site

Create a second site in your Rybbit dashboard (e.g. "My App (dev)") and use its site ID during development. Your production site's data stays untouched, and you can still verify events end-to-end.

// Next.js example
export function Analytics() {
  const siteId =
    process.env.NODE_ENV === 'development'
      ? process.env.NEXT_PUBLIC_RYBBIT_DEV_SITE_ID
      : process.env.NEXT_PUBLIC_RYBBIT_SITE_ID;

  return (
    <script
      defer
      src={`https://app.rybbit.io/api/script.js?siteId=${siteId}`}
    />
  );
}

Option 2: Only load the script in production

If you don't need analytics while developing, skip loading the script entirely outside production:

// Next.js example
export function Analytics() {
  if (process.env.NODE_ENV !== 'production') return null;

  return (
    <script
      defer
      src={`https://app.rybbit.io/api/script.js?siteId=${process.env.NEXT_PUBLIC_RYBBIT_SITE_ID}`}
    />
  );
}
// Vanilla JS example
if (process.env.NODE_ENV === 'production') {
  const script = document.createElement('script');
  script.defer = true;
  script.src = 'https://app.rybbit.io/api/script.js?siteId=YOUR_SITE_ID';
  document.head.appendChild(script);
}

Option 3: Filter the traffic instead

If you want the script loaded everywhere but excluded from your stats, use your site's exclusion settings — see Filtering Traffic and Hiding Your Own Traffic.

Troubleshooting

Events not showing up from localhost?

  • Confirm the siteId in the script URL (or data-site-id) matches the site you're looking at in the dashboard
  • Check the browser console for errors and the Network tab for POST requests to /api/track
  • Disable ad blockers or privacy extensions — they commonly block analytics scripts on any origin, including localhost
  • Make sure the page isn't excluded by your site's IP, hostname, path, or user-agent exclusion rules
  • Headless or automated browsers (Puppeteer, Playwright, Selenium) are classified as bots, so test in a normal browser

On this page